google-cloud-datastore 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed948cf1137d8762a24cdace7370bd5a1609d5954e60efcec8a3a641ebac7c3c
4
- data.tar.gz: cbbb8c6d267386d6906df1af8f5b45a75ec091a5f7dcb50136f7a1883da32aaa
3
+ metadata.gz: 74249e5a8fdd5013cb2c14ebada14d0390fba2a4656284fdf1f3b298e679f3ed
4
+ data.tar.gz: 604da27a35aaf7b9872aa64738cbf2f08c44a7b0b700fa7a5b0634bc44a132ce
5
5
  SHA512:
6
- metadata.gz: 4ada6f3aedfec41a0ef6f63bb9729c77f5640766f6fcff3084a6036949046558a5dd428698e72ec921e53d8bb25f3ee8c9f616f9e4df69ae2b0bdc021e3899ed
7
- data.tar.gz: b5b4ae1707fc512ac968d5871af9c4331af7a6700f7d048defce3bbe1fbe2fa62339410fd5632ce74fe5fe1f1f23c83b6311165f8ff2fe567d44f86695ae95cb
6
+ metadata.gz: 7c8aad1813dbfb6d6162e941a19625c5e35b29956a5511f422a61d58e1ab4beeced328347d6fb3a61a7b0255bb3e9a8d1c6121da73cd9bcbe4a2a6fb16407ad1
7
+ data.tar.gz: beb9d89d0b20a1064c56cf56d154dcba9263dfa13052b8b2604de4d6cac4735ffc08f8cb657189e74d676f89f58b050115e78721be38d0353ee7acb071e6e943
@@ -0,0 +1,178 @@
1
+ # Authentication
2
+
3
+ In general, the google-cloud-datastore library uses [Service
4
+ Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts)
5
+ credentials to connect to Google Cloud services. When running on Compute Engine
6
+ the credentials will be discovered automatically. When running on other
7
+ environments, the Service Account credentials can be specified by providing the
8
+ path to the [JSON
9
+ keyfile](https://cloud.google.com/iam/docs/managing-service-account-keys) for
10
+ the account (or the JSON itself) in environment variables. Additionally, Cloud
11
+ SDK credentials can also be discovered automatically, but this is only
12
+ recommended during development.
13
+
14
+ ## Project and Credential Lookup
15
+
16
+ The google-cloud-datastore library aims to make authentication as simple as
17
+ possible, and provides several mechanisms to configure your system without
18
+ providing **Project ID** and **Service Account Credentials** directly in code.
19
+
20
+ **Project ID** is discovered in the following order:
21
+
22
+ 1. Specify project ID in method arguments
23
+ 2. Specify project ID in configuration
24
+ 3. Discover project ID in environment variables
25
+ 4. Discover GCE project ID
26
+
27
+ **Credentials** are discovered in the following order:
28
+
29
+ 1. Specify credentials in method arguments
30
+ 2. Specify credentials in configuration
31
+ 3. Discover credentials path in environment variables
32
+ 4. Discover credentials JSON in environment variables
33
+ 5. Discover credentials file in the Cloud SDK's path
34
+ 6. Discover GCE credentials
35
+
36
+ ### Google Cloud Platform environments
37
+
38
+ While running on Google Cloud Platform environments such as Google Compute
39
+ Engine, Google App Engine and Google Kubernetes Engine, no extra work is needed.
40
+ The **Project ID** and **Credentials** and are discovered automatically. Code
41
+ should be written as if already authenticated. Just be sure when you [set up the
42
+ GCE instance][gce-how-to], you add the correct scopes for the APIs you want to
43
+ access. For example:
44
+
45
+ * **All APIs**
46
+ * `https://www.googleapis.com/auth/cloud-platform`
47
+ * `https://www.googleapis.com/auth/cloud-platform.read-only`
48
+ * **BigQuery**
49
+ * `https://www.googleapis.com/auth/bigquery`
50
+ * `https://www.googleapis.com/auth/bigquery.insertdata`
51
+ * **Compute Engine**
52
+ * `https://www.googleapis.com/auth/compute`
53
+ * **Datastore**
54
+ * `https://www.googleapis.com/auth/datastore`
55
+ * `https://www.googleapis.com/auth/userinfo.email`
56
+ * **DNS**
57
+ * `https://www.googleapis.com/auth/ndev.clouddns.readwrite`
58
+ * **Pub/Sub**
59
+ * `https://www.googleapis.com/auth/pubsub`
60
+ * **Storage**
61
+ * `https://www.googleapis.com/auth/devstorage.full_control`
62
+ * `https://www.googleapis.com/auth/devstorage.read_only`
63
+ * `https://www.googleapis.com/auth/devstorage.read_write`
64
+
65
+ ### Environment Variables
66
+
67
+ The **Project ID** and **Credentials JSON** can be placed in environment
68
+ variables instead of declaring them directly in code. Each service has its own
69
+ environment variable, allowing for different service accounts to be used for
70
+ different services. (See the READMEs for the individual service gems for
71
+ details.) The path to the **Credentials JSON** file can be stored in the
72
+ environment variable, or the **Credentials JSON** itself can be stored for
73
+ environments such as Docker containers where writing files is difficult or not
74
+ encouraged.
75
+
76
+ The environment variables that Datastore checks for project ID are:
77
+
78
+ 1. `DATASTORE_PROJECT`
79
+ 2. `GOOGLE_CLOUD_PROJECT`
80
+
81
+ The environment variables that Datastore checks for credentials are configured on {Google::Cloud::Datastore::V1::Credentials}:
82
+
83
+ 1. `DATASTORE_CREDENTIALS` - Path to JSON file, or JSON contents
84
+ 2. `DATASTORE_KEYFILE` - Path to JSON file, or JSON contents
85
+ 3. `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents
86
+ 4. `GOOGLE_CLOUD_KEYFILE` - Path to JSON file, or JSON contents
87
+ 5. `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file
88
+
89
+ ```ruby
90
+ require "google/cloud/datastore"
91
+
92
+ ENV["DATASTORE_PROJECT"] = "my-project-id"
93
+ ENV["DATASTORE_CREDENTIALS"] = "path/to/keyfile.json"
94
+
95
+ datastore = Google::Cloud::Datastore.new
96
+ ```
97
+
98
+ ### Configuration
99
+
100
+ The **Project ID** and **Credentials JSON** can be configured instead of placing them in environment variables or providing them as arguments.
101
+
102
+ ```ruby
103
+ require "google/cloud/datastore"
104
+
105
+ Google::Cloud::Datastore.configure do |config|
106
+ config.project_id = "my-project-id"
107
+ config.credentials = "path/to/keyfile.json"
108
+ end
109
+
110
+ datastore = Google::Cloud::Datastore.new
111
+ ```
112
+
113
+ ### Cloud SDK
114
+
115
+ This option allows for an easy way to authenticate during development. If
116
+ credentials are not provided in code or in environment variables, then Cloud SDK
117
+ credentials are discovered.
118
+
119
+ To configure your system for this, simply:
120
+
121
+ 1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
122
+ 2. Authenticate using OAuth 2.0 `$ gcloud auth login`
123
+ 3. Write code as if already authenticated.
124
+
125
+ **NOTE:** This is _not_ recommended for running in production. The Cloud SDK
126
+ *should* only be used during development.
127
+
128
+ [gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
129
+ [dev-console]: https://console.cloud.google.com/project
130
+
131
+ [enable-apis]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/enable-apis.png
132
+
133
+ [create-new-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account.png
134
+ [create-new-service-account-existing-keys]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account-existing-keys.png
135
+ [reuse-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/reuse-service-account.png
136
+
137
+ ## Creating a Service Account
138
+
139
+ Google Cloud requires a **Project ID** and **Service Account Credentials** to
140
+ connect to the APIs. You will use the **Project ID** and **JSON key file** to
141
+ connect to most services with google-cloud-datastore.
142
+
143
+ If you are not running this client on Google Compute Engine, you need a Google
144
+ Developers service account.
145
+
146
+ 1. Visit the [Google Developers Console][dev-console].
147
+ 1. Create a new project or click on an existing project.
148
+ 1. Activate the slide-out navigation tray and select **API Manager**. From
149
+ here, you will enable the APIs that your application requires.
150
+
151
+ ![Enable the APIs that your application requires][enable-apis]
152
+
153
+ *Note: You may need to enable billing in order to use these services.*
154
+
155
+ 1. Select **Credentials** from the side navigation.
156
+
157
+ You should see a screen like one of the following.
158
+
159
+ ![Create a new service account][create-new-service-account]
160
+
161
+ ![Create a new service account With Existing Keys][create-new-service-account-existing-keys]
162
+
163
+ Find the "Add credentials" drop down and select "Service account" to be
164
+ guided through downloading a new JSON key file.
165
+
166
+ If you want to re-use an existing service account, you can easily generate a
167
+ new key file. Just select the account you wish to re-use, and click "Generate
168
+ new JSON key":
169
+
170
+ ![Re-use an existing service account][reuse-service-account]
171
+
172
+ The key file you download will be used by this library to authenticate API
173
+ requests and should be stored in a secure location.
174
+
175
+ ## Troubleshooting
176
+
177
+ If you're having trouble authenticating you can ask for help by following the
178
+ {file:TROUBLESHOOTING.md Troubleshooting Guide}.
@@ -0,0 +1,100 @@
1
+ # Release History
2
+
3
+ ### 1.4.3 / 2018-09-12
4
+
5
+ * Update documentation.
6
+ * Add missing documentation files to package.
7
+
8
+ ### 1.4.2 / 2018-09-10
9
+
10
+ * Fix issue where client_config was not being passed when connecting to the
11
+ datastore emulator.
12
+ * Update documentation.
13
+
14
+ ### 1.4.1 / 2018-08-21
15
+
16
+ * Update documentation.
17
+
18
+ ### 1.4.0 / 2018-02-27
19
+
20
+ * Support Shared Configuration.
21
+
22
+ ### 1.3.0 / 2017-12-19
23
+
24
+ * Support Read-Only Transactions
25
+ * Add ReadOnlyTransaction class.
26
+ * Add Dataset#read_only_transaction.
27
+ * Dataset#transaction now automatically retries on error,
28
+ * Add Dataset#transaction previous_transaction and deadline arguments,
29
+ * Update google-gax dependency to 1.0.
30
+
31
+ ### 1.2.1 / 2017-11-21
32
+
33
+ * Remove warning when connecting to Datastore Emulator.
34
+
35
+ ### 1.2.0 / 2017-11-14
36
+
37
+ * Add `Google::Cloud::Datastore::Credentials` class.
38
+ * Rename constructor arguments to `project_id` and `credentials`.
39
+ (The previous arguments `project` and `keyfile` are still supported.)
40
+ * Document `Google::Auth::Credentials` as `credentials` value.
41
+ * Updated `google-gax` (`grpc`, `google-protobuf`), `googleauth` dependencies.
42
+
43
+ ### 1.1.0 / 2017-07-11
44
+
45
+ * Update GAPIC configuration to exclude `UNAVAILABLE` errors from automatic retry.
46
+ * Update gem spec homepage links.
47
+
48
+ ### 1.0.1 / 2017-05-06
49
+
50
+ * Update google-protobuf to the previous known working version
51
+
52
+ ### 1.0.0 / 2017-03-31
53
+
54
+ * Release 1.0
55
+ * Updated documentation
56
+ * Automatic retry on `UNAVAILABLE` errors
57
+
58
+ ### 0.24.2 / 2017-03-03
59
+
60
+ * No public API changes.
61
+ * Update GRPC header value sent to the Datastore API.
62
+
63
+ ### 0.24.1 / 2017-03-01
64
+
65
+ * No public API changes.
66
+ * Update GRPC header value sent to the Datastore API.
67
+
68
+ ### 0.24.0 / 2017-02-21
69
+
70
+ * Add emulator_host parameter
71
+ * Fix GRPC retry bug
72
+ * The client_config data structure has replaced retry_codes/retry_codes_def with retry_codes
73
+ * Update GRPC/Protobuf/GAX dependencies
74
+
75
+ ### 0.23.0 / 2016-12-8
76
+
77
+ * Many documentation improvements
78
+ * Add documentation for Low Level API
79
+
80
+ ### 0.21.0 / 2016-10-20
81
+
82
+ * New service constructor Google::Cloud::Datastore.new
83
+ * New constructor argument client_config
84
+ * Entity properties can now be accessed with symbols as well as strings
85
+
86
+ ### 0.20.1 / 2016-09-02
87
+
88
+ * Fix an issue with the GRPC client and forked sub-processes
89
+
90
+ ### 0.20.0 / 2016-08-26
91
+
92
+ This gem contains the Google Cloud Datastore service implementation for the `google-cloud` gem. The `google-cloud` gem replaces the old `gcloud` gem. Legacy code can continue to use the `gcloud` gem.
93
+
94
+ * Namespace is now `Google::Cloud`
95
+ * The `google-cloud` gem is now an umbrella package for individual gems
96
+
97
+ #### Changes
98
+
99
+ * Upgraded to V1
100
+ * Fix issue with embedded entities (@Dragor2)
@@ -0,0 +1,40 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct.
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or reject
24
+ comments, commits, code, wiki edits, issues, and other contributions that are
25
+ not aligned to this Code of Conduct. By adopting this Code of Conduct, project
26
+ maintainers commit themselves to fairly and consistently applying these
27
+ principles to every aspect of managing this project. Project maintainers who do
28
+ not follow or enforce the Code of Conduct may be permanently removed from the
29
+ project team.
30
+
31
+ This code of conduct applies both within project spaces and in public spaces
32
+ when an individual is representing the project or its community.
33
+
34
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
35
+ reported by opening an issue or contacting one or more of the project
36
+ maintainers.
37
+
38
+ This Code of Conduct is adapted from the [Contributor
39
+ Covenant](http://contributor-covenant.org), version 1.2.0, available at
40
+ [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
@@ -0,0 +1,209 @@
1
+ # Contributing to Google Cloud Datastore
2
+
3
+ 1. **Sign one of the contributor license agreements below.**
4
+ 2. Fork the repo, develop and test your code changes.
5
+ 3. Send a pull request.
6
+
7
+ ## Contributor License Agreements
8
+
9
+ Before we can accept your pull requests you'll need to sign a Contributor
10
+ License Agreement (CLA):
11
+
12
+ - **If you are an individual writing original source code** and **you own the
13
+ intellectual property**, then you'll need to sign an [individual
14
+ CLA](https://developers.google.com/open-source/cla/individual).
15
+ - **If you work for a company that wants to allow you to contribute your work**,
16
+ then you'll need to sign a [corporate
17
+ CLA](https://developers.google.com/open-source/cla/corporate).
18
+
19
+ You can sign these electronically (just scroll to the bottom). After that, we'll
20
+ be able to accept your pull requests.
21
+
22
+ ## Setup
23
+
24
+ In order to use the google-cloud-datastore console and run the project's tests,
25
+ there is a small amount of setup:
26
+
27
+ 1. Install Ruby. google-cloud-datastore requires Ruby 2.3+. You may choose to
28
+ manage your Ruby and gem installations with [RVM](https://rvm.io/),
29
+ [rbenv](https://github.com/rbenv/rbenv), or
30
+ [chruby](https://github.com/postmodern/chruby).
31
+
32
+ 2. Install [Bundler](http://bundler.io/).
33
+
34
+ ```sh
35
+ $ gem install bundler
36
+ ```
37
+
38
+ 3. Install the top-level project dependencies.
39
+
40
+ ```sh
41
+ $ bundle install
42
+ ```
43
+
44
+ 4. Install the Datastore dependencies.
45
+
46
+ ```sh
47
+ $ cd google-cloud-datastore/
48
+ $ bundle exec rake bundleupdate
49
+ ```
50
+
51
+ ## Console
52
+
53
+ In order to run code interactively, you can automatically load
54
+ google-cloud-datastore and its dependencies in IRB. This requires that your
55
+ developer environment has already been configured by following the steps
56
+ described in the {file:AUTHENTICATION.md Authentication Guide}. An IRB console
57
+ can be created with:
58
+
59
+ ```sh
60
+ $ cd google-cloud-datastore/
61
+ $ bundle exec rake console
62
+ ```
63
+
64
+ ## Datastore Tests
65
+
66
+ Tests are very important part of google-cloud-datastore. All contributions
67
+ should include tests that ensure the contributed code behaves as expected.
68
+
69
+ To run the unit tests, documentation tests, and code style checks together for a
70
+ package:
71
+
72
+ ``` sh
73
+ $ cd google-cloud-datastore/
74
+ $ bundle exec rake ci
75
+ ```
76
+
77
+ To run the command above, plus all acceptance tests, use `rake ci:acceptance` or
78
+ its handy alias, `rake ci:a`.
79
+
80
+ ### Datastore Unit Tests
81
+
82
+
83
+ The project uses the [minitest](https://github.com/seattlerb/minitest) library,
84
+ including [specs](https://github.com/seattlerb/minitest#specs),
85
+ [mocks](https://github.com/seattlerb/minitest#mocks) and
86
+ [minitest-autotest](https://github.com/seattlerb/minitest-autotest).
87
+
88
+ To run the Datastore unit tests:
89
+
90
+ ``` sh
91
+ $ cd google-cloud-datastore/
92
+ $ bundle exec rake test
93
+ ```
94
+
95
+ ### Datastore Documentation Tests
96
+
97
+ The project tests the code examples in the gem's
98
+ [YARD](https://github.com/lsegal/yard)-based documentation.
99
+
100
+ The example testing functions in a way that is very similar to unit testing, and
101
+ in fact the library providing it,
102
+ [yard-doctest](https://github.com/p0deje/yard-doctest), is based on the
103
+ project's unit test library, [minitest](https://github.com/seattlerb/minitest).
104
+
105
+ To run the Datastore documentation tests:
106
+
107
+ ``` sh
108
+ $ cd google-cloud-datastore/
109
+ $ bundle exec rake doctest
110
+ ```
111
+
112
+ If you add, remove or modify documentation examples when working on a pull
113
+ request, you may need to update the setup for the tests. The stubs and mocks
114
+ required to run the tests are located in `support/doctest_helper.rb`. Please
115
+ note that much of the setup is matched by the title of the
116
+ [`@example`](http://www.rubydoc.info/gems/yard/file/docs/Tags.md#example) tag.
117
+ If you alter an example's title, you may encounter breaking tests.
118
+
119
+ ### Datastore Acceptance Tests
120
+
121
+ The Datastore acceptance tests interact with the live service API. Follow the
122
+ instructions in the {file:AUTHENTICATION.md Authentication guide} for enabling
123
+ the Datastore API. Occasionally, some API features may not yet be generally
124
+ available, making it difficult for some contributors to successfully run the
125
+ entire acceptance test suite. However, please ensure that you do successfully
126
+ run acceptance tests for any code areas covered by your pull request.
127
+
128
+ To run the acceptance tests, first create and configure a project in the Google
129
+ Developers Console, as described in the {file:AUTHENTICATION.md Authentication
130
+ guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
131
+ the KEYFILE location on your system.
132
+
133
+ Before you can run the Datastore acceptance tests, you must first create indexes
134
+ used in the tests.
135
+
136
+ #### Create Datastore indexes
137
+
138
+ Install the [gcloud command-line
139
+ tool](https://developers.google.com/cloud/sdk/gcloud/) and use it to create the
140
+ indexes used in the datastore acceptance tests. From the project's root
141
+ directory:
142
+
143
+ ``` sh
144
+ # Install the app component
145
+ $ gcloud components update app
146
+
147
+ # Set the default project in your env
148
+ $ gcloud config set project PROJECT_ID
149
+
150
+ # Authenticate the gcloud tool with your account
151
+ $ gcloud auth login
152
+
153
+ # Create the indexes
154
+ $ gcloud preview datastore create-indexes acceptance/data/
155
+ ```
156
+
157
+ #### Running the Datastore acceptance tests
158
+
159
+ To run the Datastore acceptance tests:
160
+
161
+ ``` sh
162
+ $ cd google-cloud-datastore/
163
+ $ bundle exec rake acceptance[\\{my-project-id},\\{/path/to/keyfile.json}]
164
+ ```
165
+
166
+ Or, if you prefer you can store the values in the `GCLOUD_TEST_PROJECT` and
167
+ `GCLOUD_TEST_KEYFILE` environment variables:
168
+
169
+ ``` sh
170
+ $ cd google-cloud-datastore/
171
+ $ export GCLOUD_TEST_PROJECT=\\{my-project-id}
172
+ $ export GCLOUD_TEST_KEYFILE=\\{/path/to/keyfile.json}
173
+ $ bundle exec rake acceptance
174
+ ```
175
+
176
+ If you want to use a different project and credentials for acceptance tests, you
177
+ can use the more specific `DATASTORE_TEST_PROJECT` and `DATASTORE_TEST_KEYFILE`
178
+ environment variables:
179
+
180
+ ``` sh
181
+ $ cd google-cloud-datastore/
182
+ $ export DATASTORE_TEST_PROJECT=\\{my-project-id}
183
+ $ export DATASTORE_TEST_KEYFILE=\\{/path/to/keyfile.json}
184
+ $ bundle exec rake acceptance
185
+ ```
186
+
187
+ ## Coding Style
188
+
189
+ Please follow the established coding style in the library. The style is is
190
+ largely based on [The Ruby Style
191
+ Guide](https://github.com/bbatsov/ruby-style-guide) with a few exceptions based
192
+ on seattle-style:
193
+
194
+ * Avoid parenthesis when possible, including in method definitions.
195
+ * Always use double quotes strings. ([Option
196
+ B](https://github.com/bbatsov/ruby-style-guide#strings))
197
+
198
+ You can check your code against these rules by running Rubocop like so:
199
+
200
+ ```sh
201
+ $ cd google-cloud-datastore/
202
+ $ bundle exec rake rubocop
203
+ ```
204
+
205
+ ## Code of Conduct
206
+
207
+ Please note that this project is released with a Contributor Code of Conduct. By
208
+ participating in this project you agree to abide by its terms. See
209
+ {file:CODE_OF_CONDUCT.md Code of Conduct} for more information.