|
12 | 12 |
|
13 | 13 | This client supports the following Google Cloud Platform services at a [General Availability (GA)](#versioning) quality level: |
14 | 14 |
|
| 15 | +* [Cloud Datastore](#cloud-datastore-ga) (GA) |
15 | 16 | * [Cloud Storage](#cloud-storage-ga) (GA) |
| 17 | +* [Google Stackdriver Logging](#google-stackdriver-logging-ga) (GA) |
16 | 18 |
|
17 | 19 | This client supports the following Google Cloud Platform services at a [Beta](#versioning) quality level: |
18 | 20 |
|
19 | | -* [Cloud Datastore](#cloud-datastore-beta) (Beta) |
20 | 21 | * [Cloud Natural Language](#cloud-natural-language-beta) (Beta) |
21 | 22 | * [Cloud Translation API](#cloud-translation-api-beta) (Beta) |
22 | 23 | * [Cloud Vision](#cloud-vision-beta) (Beta) |
23 | 24 | * [Google BigQuery](#google-bigquery-beta) (Beta) |
24 | | -* [Google Stackdriver Logging](#google-stackdriver-logging-beta) (Beta) |
25 | 25 |
|
26 | 26 | This client supports the following Google Cloud Platform services at an [Alpha](#versioning) quality level: |
27 | 27 |
|
@@ -153,6 +153,69 @@ var gcloud = require('google-cloud')({ |
153 | 153 | You can also set auth on a per-API-instance basis. The examples below show you how. |
154 | 154 |
|
155 | 155 |
|
| 156 | +## Cloud Datastore (GA) |
| 157 | + |
| 158 | +- [API Documentation][gcloud-datastore-docs] |
| 159 | +- [Official Documentation][cloud-datastore-docs] |
| 160 | + |
| 161 | +*Follow the [activation instructions][cloud-datastore-activation] to use the Cloud Datastore API with your project.* |
| 162 | + |
| 163 | +#### Using the Cloud Datastore API module |
| 164 | + |
| 165 | +``` |
| 166 | +$ npm install --save @google-cloud/datastore |
| 167 | +``` |
| 168 | + |
| 169 | +```js |
| 170 | +var datastore = require('@google-cloud/datastore'); |
| 171 | +``` |
| 172 | + |
| 173 | +#### Preview |
| 174 | + |
| 175 | +```js |
| 176 | +// Authenticating on a per-API-basis. You don't need to do this if you auth on a |
| 177 | +// global basis (see Authentication section above). |
| 178 | + |
| 179 | +var datastoreClient = datastore({ |
| 180 | + projectId: 'grape-spaceship-123', |
| 181 | + keyFilename: '/path/to/keyfile.json' |
| 182 | +}); |
| 183 | + |
| 184 | +var key = datastoreClient.key(['Product', 'Computer']); |
| 185 | + |
| 186 | +datastoreClient.get(key, function(err, entity) { |
| 187 | + console.log(err || entity); |
| 188 | +}); |
| 189 | + |
| 190 | +// Save data to Datastore. |
| 191 | +var blogPostData = { |
| 192 | + title: 'How to make the perfect homemade pasta', |
| 193 | + author: 'Andrew Chilton', |
| 194 | + isDraft: true |
| 195 | +}; |
| 196 | + |
| 197 | +var blogPostKey = datastoreClient.key('BlogPost'); |
| 198 | + |
| 199 | +datastoreClient.save({ |
| 200 | + key: blogPostKey, |
| 201 | + data: blogPostData |
| 202 | +}, function(err) { |
| 203 | + // `blogPostKey` has been updated with an ID so you can do more operations |
| 204 | + // with it, such as an update. |
| 205 | + blogPostData.isDraft = false; |
| 206 | + |
| 207 | + datastoreClient.save({ |
| 208 | + key: blogPostKey, |
| 209 | + data: blogPostData |
| 210 | + }, function(err) { |
| 211 | + if (!err) { |
| 212 | + // The blog post is now published! |
| 213 | + } |
| 214 | + }); |
| 215 | +}); |
| 216 | +``` |
| 217 | + |
| 218 | + |
156 | 219 | ## Cloud Storage (GA) |
157 | 220 |
|
158 | 221 | - [API Documentation][gcloud-storage-docs] |
@@ -214,65 +277,63 @@ localReadStream.pipe(remoteWriteStream); |
214 | 277 | ``` |
215 | 278 |
|
216 | 279 |
|
217 | | -## Cloud Datastore (Beta) |
218 | | - |
219 | | -- [API Documentation][gcloud-datastore-docs] |
220 | | -- [Official Documentation][cloud-datastore-docs] |
| 280 | +## Google Stackdriver Logging (Beta) |
221 | 281 |
|
222 | | -*Follow the [activation instructions][cloud-datastore-activation] to use the Cloud Datastore API with your project.* |
| 282 | +- [API Documentation][gcloud-logging-docs] |
| 283 | +- [Official Documentation][cloud-logging-docs] |
223 | 284 |
|
224 | | -#### Using the Cloud Datastore API module |
| 285 | +#### Using the Google Stackdriver Logging API module |
225 | 286 |
|
226 | 287 | ``` |
227 | | -$ npm install --save @google-cloud/datastore |
| 288 | +$ npm install --save @google-cloud/logging |
228 | 289 | ``` |
229 | 290 |
|
230 | 291 | ```js |
231 | | -var datastore = require('@google-cloud/datastore'); |
| 292 | +var logging = require('@google-cloud/logging'); |
232 | 293 | ``` |
233 | 294 |
|
234 | 295 | #### Preview |
235 | 296 |
|
236 | 297 | ```js |
237 | | -// Authenticating on a per-API-basis. You don't need to do this if you auth on a |
238 | | -// global basis (see Authentication section above). |
| 298 | +// Authenticating on a global-basis. You can also authenticate on a per-API- |
| 299 | +// basis (see Authentication section above). |
239 | 300 |
|
240 | | -var datastoreClient = datastore({ |
| 301 | +var loggingClient = logging({ |
241 | 302 | projectId: 'grape-spaceship-123', |
242 | 303 | keyFilename: '/path/to/keyfile.json' |
243 | 304 | }); |
244 | 305 |
|
245 | | -var key = datastoreClient.key(['Product', 'Computer']); |
| 306 | +// Create a sink using a Bucket as a destination. |
| 307 | +var gcs = storage(); |
246 | 308 |
|
247 | | -datastoreClient.get(key, function(err, entity) { |
248 | | - console.log(err || entity); |
249 | | -}); |
| 309 | +loggingClient.createSink('my-new-sink', { |
| 310 | + destination: gcs.bucket('my-sink') |
| 311 | +}, function(err, sink) {}); |
250 | 312 |
|
251 | | -// Save data to Datastore. |
252 | | -var blogPostData = { |
253 | | - title: 'How to make the perfect homemade pasta', |
254 | | - author: 'Andrew Chilton', |
255 | | - isDraft: true |
| 313 | +// Write a critical entry to a log. |
| 314 | +var syslog = loggingClient.log('syslog'); |
| 315 | + |
| 316 | +var metadata = { |
| 317 | + resource: { |
| 318 | + type: 'gce_instance', |
| 319 | + labels: { |
| 320 | + zone: 'global', |
| 321 | + instance_id: '3' |
| 322 | + } |
| 323 | + } |
256 | 324 | }; |
257 | 325 |
|
258 | | -var blogPostKey = datastoreClient.key('BlogPost'); |
| 326 | +var entry = syslog.entry(metadata, { |
| 327 | + delegate: process.env.user |
| 328 | +}); |
259 | 329 |
|
260 | | -datastoreClient.save({ |
261 | | - key: blogPostKey, |
262 | | - data: blogPostData |
263 | | -}, function(err) { |
264 | | - // `blogPostKey` has been updated with an ID so you can do more operations |
265 | | - // with it, such as an update. |
266 | | - blogPostData.isDraft = false; |
| 330 | +syslog.critical(entry, function(err) {}); |
267 | 331 |
|
268 | | - datastoreClient.save({ |
269 | | - key: blogPostKey, |
270 | | - data: blogPostData |
271 | | - }, function(err) { |
272 | | - if (!err) { |
273 | | - // The blog post is now published! |
274 | | - } |
275 | | - }); |
| 332 | +// Get all entries in your project. |
| 333 | +loggingClient.getEntries(function(err, entries) { |
| 334 | + if (!err) { |
| 335 | + // `entries` contains all of the entries from the logs in your project. |
| 336 | + } |
276 | 337 | }); |
277 | 338 | ``` |
278 | 339 |
|
@@ -629,67 +690,6 @@ job.getQueryResults().on('data', function(row) {}); |
629 | 690 | ``` |
630 | 691 |
|
631 | 692 |
|
632 | | -## Google Stackdriver Logging (Beta) |
633 | | - |
634 | | -- [API Documentation][gcloud-logging-docs] |
635 | | -- [Official Documentation][cloud-logging-docs] |
636 | | - |
637 | | -#### Using the Google Stackdriver Logging API module |
638 | | - |
639 | | -``` |
640 | | -$ npm install --save @google-cloud/logging |
641 | | -``` |
642 | | - |
643 | | -```js |
644 | | -var logging = require('@google-cloud/logging'); |
645 | | -``` |
646 | | - |
647 | | -#### Preview |
648 | | - |
649 | | -```js |
650 | | -// Authenticating on a global-basis. You can also authenticate on a per-API- |
651 | | -// basis (see Authentication section above). |
652 | | - |
653 | | -var loggingClient = logging({ |
654 | | - projectId: 'grape-spaceship-123', |
655 | | - keyFilename: '/path/to/keyfile.json' |
656 | | -}); |
657 | | - |
658 | | -// Create a sink using a Bucket as a destination. |
659 | | -var gcs = storage(); |
660 | | - |
661 | | -loggingClient.createSink('my-new-sink', { |
662 | | - destination: gcs.bucket('my-sink') |
663 | | -}, function(err, sink) {}); |
664 | | - |
665 | | -// Write a critical entry to a log. |
666 | | -var syslog = loggingClient.log('syslog'); |
667 | | - |
668 | | -var metadata = { |
669 | | - resource: { |
670 | | - type: 'gce_instance', |
671 | | - labels: { |
672 | | - zone: 'global', |
673 | | - instance_id: '3' |
674 | | - } |
675 | | - } |
676 | | -}; |
677 | | - |
678 | | -var entry = syslog.entry(metadata, { |
679 | | - delegate: process.env.user |
680 | | -}); |
681 | | - |
682 | | -syslog.critical(entry, function(err) {}); |
683 | | - |
684 | | -// Get all entries in your project. |
685 | | -loggingClient.getEntries(function(err, entries) { |
686 | | - if (!err) { |
687 | | - // `entries` contains all of the entries from the logs in your project. |
688 | | - } |
689 | | -}); |
690 | | -``` |
691 | | - |
692 | | - |
693 | 693 | ## Cloud Bigtable (Alpha) |
694 | 694 |
|
695 | 695 | - [API Documentation][gcloud-bigtable-docs] |
|
0 commit comments