Skip to content

Commit 0f618d2

Browse files
author
Burcu Dogan
committed
Merge pull request #149 from silvolu/master
docs(README): bunch of rewritings
2 parents 0ae0917 + 5218d9b commit 0f618d2

File tree

1 file changed

+36
-142
lines changed

1 file changed

+36
-142
lines changed

README.md

+36-142
Original file line numberDiff line numberDiff line change
@@ -7,193 +7,87 @@
77

88
This client supports the following Google Cloud services:
99

10-
* [Google Cloud Datastore](https://developers.google.com/datastore/)
10+
* [Google Cloud Datastore](https://cloud.google.com/products/cloud-datastore/)
1111
* [Google Cloud Storage](https://cloud.google.com/products/cloud-storage/)
12-
* [Google Cloud Pub/Sub (experimental)](https://developers.google.com/pubsub/)
13-
14-
Planned, but not yet available:
15-
16-
* [Google Compute Engine](https://developers.google.com/compute)
17-
* [Google BigQuery](https://developers.google.com/bigquery/)
1812

1913
## Quickstart
2014

2115
```sh
2216
$ npm install gcloud
2317
```
2418

19+
## Authorization
20+
2521
### On Google Compute Engine
2622

27-
If you are running this client on Google Compute Engine, you can skip to the developer's guide. We handle authorisation for you with no configuration.
23+
If you are running this client on Google Compute Engine, we handle authorization for you with no configuration. You just need to make sure that when you [set up the GCE instance](https://developers.google.com/compute/docs/authentication#using), you add the correct scopes for the APIs you want to access.
2824

2925
### Elsewhere
3026

3127
If you are not running this client on Google Compute Engine, you need a Google Developers service account. To create a service account:
3228

3329
1. Visit the [Google Developers Console](https://console.developers.google.com/project).
3430
2. Create a new project or click on an existing project.
35-
3. Enable billing if you haven't already.
36-
4. On the "APIs & auth" tab, click APIs section and turn on the following. You may need to enable billing in order to use these services.
31+
3. Navigate to **APIs & auth** > **APIs section** and turn on the following APIs (you may need to enable billing in order to use these services):
3732
* Google Cloud Datastore API
3833
* Google Cloud Storage
3934
* Google Cloud Storage JSON API
40-
* Google Cloud Pub/Sub
41-
5. Once API access is enabled, switch back to "APIs & auth" section on the navigation panel and switch to "Credentials" page.
42-
6. Click on "Create new client ID" to create a new **service account**. Once the account is created, click on "Generate new JSON key" to download your private key. The downloaded file contains credentials you'll need for authorization.
43-
44-
You'll need the following for auth configuration:
45-
46-
1. Your Developers Console project's ID (e.g. bamboo-shift-455).
47-
2. The path to the JSON key file.
35+
4. Navigate to **APIs & auth** > **Credentials** and then:
36+
* If you want to use a new service account, click on **Create new client ID**. After the account is created, you will be prompted to download the JSON key file that the library uses to authorize your requests.
37+
* If you want to generate a new key for an existing service account, click on **Generate new JSON key** and download the JSON key file.
4838

49-
### Google Cloud Datastore
39+
## Google Cloud Datastore
5040

5141
[Google Cloud Datastore](https://developers.google.com/datastore/) is a fully managed, schemaless database for storing non-relational data. Cloud Datastore automatically scales with your users and supports ACID transactions, high availability of reads and writes, strong consistency for reads and ancestor queries, and eventual consistency for all other queries.
5242

53-
See [the API documentation](https://googlecloudplatform.github.io/gcloud-node/module-datastore.html) for how to interact with the Datastore.
54-
55-
### Google Cloud Storage
56-
57-
Google Cloud Storage allows you to store data on Google infrastructure. Read [Google Cloud Storage API docs](https://developers.google.com/storage/) for more information.
58-
59-
You need to create a Google Cloud Storage bucket to use this client library. Follow the steps on [Google Cloud Storage docs](https://developers.google.com/storage/) to create a bucket.
60-
61-
See [the API documentation](https://googlecloudplatform.github.io/gcloud-node/module-storage.html) for how to connect to the Storage API.
62-
63-
### Google Cloud Pub/Sub (experimental)
43+
See the [Google Cloud Datastore docs](https://developers.google.com/datastore/docs/activate) for more details on how to activate Cloud Datastore for your project.
6444

65-
Google Cloud Pub/Sub is a reliable, many-to-many, asynchronous messaging
66-
service from Google Cloud Platform. A detailed overview is available on
67-
[Pub/Sub docs](https://developers.google.com/pubsub/overview).
68-
69-
Note: Google Cloud Pub/Sub API is available as a Limited Preview and the
70-
client library we provide is currently experimental. The API and/or the
71-
client might be changed in backward-incompatible ways.
72-
This API is not subject to any SLA or deprecation policy. Request to be
73-
whitelisted to use it by filling the [Limited Preview application form](https://docs.google.com/a/google.com/forms/d/1IQY4LAbISLa86uxRv2dKAzkeWOyNZda_tUn7xgVYeoE/viewform).
74-
75-
#### Configuration
76-
77-
If you're running this client on Google Compute Engine, you need to construct
78-
a pubsub Connection with your Google Developers Console project ID.
79-
80-
```js
81-
var gcloud = require('gcloud');
82-
var conn = new gcloud.pubsub.Connection({
83-
projectId: YOUR_PROJECT_ID
84-
});
85-
```
86-
87-
Elsewhere, construct with a project ID, service account's email, and private key downloaded from Developer's Console.
45+
See [the API documentation](https://googlecloudplatform.github.io/gcloud-node/module-datastore.html) to learn how to interact with the Cloud Datastore using this Client Library.
8846

8947
```js
9048
var gcloud = require('gcloud');
91-
var conn = new gcloud.pubsub.Connection({
92-
projectId: YOUR_PROJECT_ID,
93-
keyFilename: '/path/to/the/key.json'
94-
});
95-
```
96-
97-
#### Topics and Subscriptions
98-
99-
List, get, create and delete topics.
100-
101-
```js
102-
// Lists topics.
103-
conn.listTopics({
104-
maxResults: 5
105-
}, function(err, topics, nextQuery) {
106-
// If there are more results, nextQuery will be non-null.
107-
});
108-
109-
// Retrieve an existing topic by name.
110-
conn.getTopic('topic1', function(err, topic) {
111-
// Delete this topic.
112-
topic.del(callback);
113-
});
114-
115-
// Creates a new topic named topic2.
116-
conn.createTopic('topic2', callback);
117-
```
49+
var datastore = gcloud.datastore;
50+
var dataset;
11851

119-
List, get, create and delete subscriptions.
120-
121-
```js
122-
var query = {
123-
maxResults: 5,
124-
filterByTopicName: 'topic1'
125-
};
126-
127-
// List 5 subscriptions that are subscribed to topic1.
128-
conn.listSubscriptions(query, function(err, subs, nextQuery) {
129-
// if there are more results, nextQuery will be non-null.
52+
// From Google Compute Engine
53+
dataset = new datastore.Dataset({
54+
projectId: 'my-project',
13055
});
13156

132-
// Get a subscription named sub1.
133-
conn.getSubscription('sub1', function(err, sub) {
134-
// delete this subscription.
135-
sub.del(callback);
57+
// From elsewhere
58+
dataset = new datastore.Dataset({
59+
projectId: 'my-project',
60+
keyFilename: '/path/to/keyfile.json'
13661
});
13762

138-
// Create a new subsription named sub2 which listens to topic1.
139-
conn.createSubscription({
140-
topic: 'topic1',
141-
name: 'sub2',
142-
ackDeadlineSeconds: 60
143-
}, callback);
63+
dataset.get(dataset.key('Product', 'Computer'), function(err, entity) {});
14464
```
14565

146-
#### Publishing a message
147-
148-
You need to retrieve or create a topic to publish a message. You can either
149-
publish simple string messages or a raw Pub/Sub message object.
66+
## Google Cloud Storage
15067

151-
```js
152-
conn.getTopic('topic1', function(err, topic) {
153-
// Publish "hello world" to topic1's subscribers.
154-
topic.publish('hello world', callback);
155-
topic.publishMessage({
156-
data: 'Some text here...',
157-
label: [
158-
{
159-
key: 'priority',
160-
numValue: 0
161-
},
162-
{
163-
key: 'foo',
164-
stringValue: 'bar'
165-
}
166-
]
167-
}, callback);
168-
});
169-
```
68+
[Google Cloud Storage](https://developers.google.com/storage/) allows you to store data on Google infrastructure with very high reliability, performance and availability, and can be used to distribute large data objects to users via direct download.
17069

171-
#### Listening for messages
70+
You need to create a Google Cloud Storage bucket to use this client library. Follow the steps on the [Google Cloud Storage docs](https://developers.google.com/storage/docs/cloud-console#_creatingbuckets) to learn how to create a bucket.
17271

173-
You can either pull messages one by one via a subscription, or let the client
174-
open a long-lived request to poll them.
72+
See [the API documentation](https://googlecloudplatform.github.io/gcloud-node/module-storage.html) to learn how to connect to the Cloud Storage using this Client Library.
17573

17674
```js
177-
// Allow client to poll messages from sub1.
178-
// `autoAck` automatically acknowledges the messages. (default: false)
179-
var sub = conn.subscribe('sub1', {
180-
autoAck: true
181-
});
182-
183-
sub.on('ready', function() {
184-
console.log('Listening for messages...');
185-
});
75+
var gcloud = require('gcloud');
76+
var storage = gcloud.storage;
77+
var bucket;
18678

187-
sub.on('message', function(msg) {
188-
console.log('Message retrieved:', msg);
79+
// From Google Compute Engine
80+
bucket = new storage.Bucket({
81+
bucketName: YOUR_BUCKET_NAME
18982
});
19083

191-
sub.on('error', function(err) {
192-
console.log('An error occurred:', err);
84+
// From elsewhere
85+
bucket = new storage.Bucket({
86+
bucketName: YOUR_BUCKET_NAME,
87+
keyFilename: '/path/to/the/key.json'
19388
});
19489

195-
// Closes the connection and stop listening for messages.
196-
sub.close();
90+
bucket.write('filename', 'Hello World', function(err) {});
19791
```
19892

19993
## Contributing

0 commit comments

Comments
 (0)