google-cloud-os_login 0.2.3 → 0.2.4

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: e8cdae0a589d24e382da03a1995c496c1e04610a88209cb238ebff72ed5416e5
4
- data.tar.gz: 174330914db6ad525fa26558c701b6e607173296f0abb0ede672c5440b0dda24
3
+ metadata.gz: '00835896ab7d149057548174a28a78b1216ed852bb3f845e50ab15baa731e590'
4
+ data.tar.gz: a64bc7e03995876c70e71835febf619b08dda3d2e8cc9b8e2b60f74d2f9ce149
5
5
  SHA512:
6
- metadata.gz: 6314096ed8e44109c513a8b844c9cb86039992c32cc48221964af2cb2277d4fa752044610288ad12a51de7b08e641e9486a03e71c2ef73151cefec6bf35134a2
7
- data.tar.gz: eb4319c90fa1733d6e45b67576e699788908f370fc506199a97ae184b2b8b50c605974de6a687112803953f2e1b5246d0f5ab6378f103a38387eded63ba42d44
6
+ metadata.gz: e34a7f48b5f4a2d6757ca9a04514408cc75191710c45e5b1964eda801a0a9c03645a573d7e2695bed2d3f787ff6294d3d38d286fe3039c0822823279570ed7f0
7
+ data.tar.gz: 7631ec87db2f67152f801e73e6b1e0f3fd804c2b50f039df8c8a45e6e4a0d8bb39b8c72b2f4987dfec83fec92c349acde8b301b42705a23bbac22986d8835578
data/.yardopts CHANGED
@@ -7,3 +7,5 @@
7
7
  ./lib/**/*.rb
8
8
  -
9
9
  README.md
10
+ AUTHENTICATION.md
11
+ LICENSE
data/AUTHENTICATION.md ADDED
@@ -0,0 +1,199 @@
1
+ # Authentication
2
+
3
+ In general, the google-cloud-os_login 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 within [Google
6
+ Cloud Platform environments](#google-cloud-platform-environments)
7
+ the credentials will be discovered automatically. When running on other
8
+ environments, the Service Account credentials can be specified by providing the
9
+ path to the [JSON
10
+ keyfile](https://cloud.google.com/iam/docs/managing-service-account-keys) for
11
+ the account (or the JSON itself) in [environment
12
+ variables](#environment-variables). Additionally, Cloud SDK credentials can also
13
+ be discovered automatically, but this is only recommended during development.
14
+
15
+ ## Quickstart
16
+
17
+ 1. [Create a service account and credentials](#creating-a-service-account).
18
+ 2. Set the [environment variable](#environment-variables).
19
+
20
+ ```sh
21
+ export OS_LOGIN_CREDENTIALS=/path/to/json`
22
+ ```
23
+
24
+ 3. Initialize the client.
25
+
26
+ ```ruby
27
+ require "google/cloud/os_login"
28
+
29
+ client = Google::Cloud::OsLogin.new
30
+ ```
31
+
32
+ ## Project and Credential Lookup
33
+
34
+ The google-cloud-os_login library aims to make authentication
35
+ as simple as possible, and provides several mechanisms to configure your system
36
+ without providing **Project ID** and **Service Account Credentials** directly in
37
+ code.
38
+
39
+ **Project ID** is discovered in the following order:
40
+
41
+ 1. Specify project ID in method arguments
42
+ 2. Specify project ID in configuration
43
+ 3. Discover project ID in environment variables
44
+ 4. Discover GCE project ID
45
+ 5. Discover project ID in credentials JSON
46
+
47
+ **Credentials** are discovered in the following order:
48
+
49
+ 1. Specify credentials in method arguments
50
+ 2. Specify credentials in configuration
51
+ 3. Discover credentials path in environment variables
52
+ 4. Discover credentials JSON in environment variables
53
+ 5. Discover credentials file in the Cloud SDK's path
54
+ 6. Discover GCE credentials
55
+
56
+ ### Google Cloud Platform environments
57
+
58
+ While running on Google Cloud Platform environments such as Google Compute
59
+ Engine, Google App Engine and Google Kubernetes Engine, no extra work is needed.
60
+ The **Project ID** and **Credentials** and are discovered automatically. Code
61
+ should be written as if already authenticated. Just be sure when you [set up the
62
+ GCE instance][gce-how-to], you add the correct scopes for the APIs you want to
63
+ access. For example:
64
+
65
+ * **All APIs**
66
+ * `https://www.googleapis.com/auth/cloud-platform`
67
+ * `https://www.googleapis.com/auth/cloud-platform.read-only`
68
+ * **BigQuery**
69
+ * `https://www.googleapis.com/auth/bigquery`
70
+ * `https://www.googleapis.com/auth/bigquery.insertdata`
71
+ * **Compute Engine**
72
+ * `https://www.googleapis.com/auth/compute`
73
+ * **Datastore**
74
+ * `https://www.googleapis.com/auth/datastore`
75
+ * `https://www.googleapis.com/auth/userinfo.email`
76
+ * **DNS**
77
+ * `https://www.googleapis.com/auth/ndev.clouddns.readwrite`
78
+ * **Pub/Sub**
79
+ * `https://www.googleapis.com/auth/pubsub`
80
+ * **Storage**
81
+ * `https://www.googleapis.com/auth/devstorage.full_control`
82
+ * `https://www.googleapis.com/auth/devstorage.read_only`
83
+ * `https://www.googleapis.com/auth/devstorage.read_write`
84
+
85
+ ### Environment Variables
86
+
87
+ The **Project ID** and **Credentials JSON** can be placed in environment
88
+ variables instead of declaring them directly in code. Each service has its own
89
+ environment variable, allowing for different service accounts to be used for
90
+ different services. (See the READMEs for the individual service gems for
91
+ details.) The path to the **Credentials JSON** file can be stored in the
92
+ environment variable, or the **Credentials JSON** itself can be stored for
93
+ environments such as Docker containers where writing files is difficult or not
94
+ encouraged.
95
+
96
+ The environment variables that google-cloud-os_login checks for project ID are:
97
+
98
+ 1. `OS_LOGIN_PROJECT`
99
+ 2. `GOOGLE_CLOUD_PROJECT`
100
+
101
+ The environment variables that google-cloud-os_login checks for credentials are configured on {Google::Cloud::OsLogin::V1::Credentials}:
102
+
103
+ 1. `OS_LOGIN_CREDENTIALS` - Path to JSON file, or JSON contents
104
+ 2. `OS_LOGIN_KEYFILE` - Path to JSON file, or JSON contents
105
+ 3. `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents
106
+ 4. `GOOGLE_CLOUD_KEYFILE` - Path to JSON file, or JSON contents
107
+ 5. `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file
108
+
109
+ ```ruby
110
+ require "google/cloud/os_login"
111
+
112
+ ENV["OS_LOGIN_PROJECT"] = "my-project-id"
113
+ ENV["OS_LOGIN_CREDENTIALS"] = "path/to/keyfile.json"
114
+
115
+ client = Google::Cloud::OsLogin.new
116
+ ```
117
+
118
+ ### Configuration
119
+
120
+ The **Project ID** and **Credentials JSON** can be configured instead of placing them in environment variables or providing them as arguments.
121
+
122
+ ```ruby
123
+ require "google/cloud/os_login"
124
+
125
+ Google::Cloud::OsLogin.configure do |config|
126
+ config.project_id = "my-project-id"
127
+ config.credentials = "path/to/keyfile.json"
128
+ end
129
+
130
+ client = Google::Cloud::OsLogin.new
131
+ ```
132
+
133
+ ### Cloud SDK
134
+
135
+ This option allows for an easy way to authenticate during development. If
136
+ credentials are not provided in code or in environment variables, then Cloud SDK
137
+ credentials are discovered.
138
+
139
+ To configure your system for this, simply:
140
+
141
+ 1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
142
+ 2. Authenticate using OAuth 2.0 `$ gcloud auth login`
143
+ 3. Write code as if already authenticated.
144
+
145
+ **NOTE:** This is _not_ recommended for running in production. The Cloud SDK
146
+ *should* only be used during development.
147
+
148
+ [gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
149
+ [dev-console]: https://console.cloud.google.com/project
150
+
151
+ [enable-apis]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/enable-apis.png
152
+
153
+ [create-new-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account.png
154
+ [create-new-service-account-existing-keys]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account-existing-keys.png
155
+ [reuse-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/reuse-service-account.png
156
+
157
+ ## Creating a Service Account
158
+
159
+ Google Cloud requires a **Project ID** and **Service Account Credentials** to
160
+ connect to the APIs. You will use the **Project ID** and **JSON key file** to
161
+ connect to most services with google-cloud-os_login.
162
+
163
+ If you are not running this client within [Google Cloud Platform
164
+ environments](#google-cloud-platform-environments), you need a Google
165
+ Developers service account.
166
+
167
+ 1. Visit the [Google Developers Console][dev-console].
168
+ 1. Create a new project or click on an existing project.
169
+ 1. Activate the slide-out navigation tray and select **API Manager**. From
170
+ here, you will enable the APIs that your application requires.
171
+
172
+ ![Enable the APIs that your application requires][enable-apis]
173
+
174
+ *Note: You may need to enable billing in order to use these services.*
175
+
176
+ 1. Select **Credentials** from the side navigation.
177
+
178
+ You should see a screen like one of the following.
179
+
180
+ ![Create a new service account][create-new-service-account]
181
+
182
+ ![Create a new service account With Existing Keys][create-new-service-account-existing-keys]
183
+
184
+ Find the "Add credentials" drop down and select "Service account" to be
185
+ guided through downloading a new JSON key file.
186
+
187
+ If you want to re-use an existing service account, you can easily generate a
188
+ new key file. Just select the account you wish to re-use, and click "Generate
189
+ new JSON key":
190
+
191
+ ![Re-use an existing service account][reuse-service-account]
192
+
193
+ The key file you download will be used by this library to authenticate API
194
+ requests and should be stored in a secure location.
195
+
196
+ ## Troubleshooting
197
+
198
+ If you're having trouble authenticating you can ask for help by following the
199
+ {file:TROUBLESHOOTING.md Troubleshooting Guide}.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -83,57 +83,49 @@ module Google
83
83
  # describe the updated values, the API ignores the values of all
84
84
  # fields not covered by the mask.
85
85
  #
86
- # If a repeated field is specified for an update operation, the existing
87
- # repeated values in the target resource will be overwritten by the new values.
88
- # Note that a repeated field is only allowed in the last position of a `paths`
89
- # string.
86
+ # If a repeated field is specified for an update operation, new values will
87
+ # be appended to the existing repeated field in the target resource. Note that
88
+ # a repeated field is only allowed in the last position of a `paths` string.
90
89
  #
91
90
  # If a sub-message is specified in the last position of the field mask for an
92
- # update operation, then the existing sub-message in the target resource is
93
- # overwritten. Given the target message:
91
+ # update operation, then new value will be merged into the existing sub-message
92
+ # in the target resource.
93
+ #
94
+ # For example, given the target message:
94
95
  #
95
96
  # f {
96
97
  # b {
97
- # d : 1
98
- # x : 2
98
+ # d: 1
99
+ # x: 2
99
100
  # }
100
- # c : 1
101
+ # c: [1]
101
102
  # }
102
103
  #
103
104
  # And an update message:
104
105
  #
105
106
  # f {
106
107
  # b {
107
- # d : 10
108
+ # d: 10
108
109
  # }
110
+ # c: [2]
109
111
  # }
110
112
  #
111
113
  # then if the field mask is:
112
114
  #
113
- # paths: "f.b"
115
+ # paths: ["f.b", "f.c"]
114
116
  #
115
117
  # then the result will be:
116
118
  #
117
119
  # f {
118
120
  # b {
119
- # d : 10
121
+ # d: 10
122
+ # x: 2
120
123
  # }
121
- # c : 1
124
+ # c: [1, 2]
122
125
  # }
123
126
  #
124
- # However, if the update mask was:
125
- #
126
- # paths: "f.b.d"
127
- #
128
- # then the result would be:
129
- #
130
- # f {
131
- # b {
132
- # d : 10
133
- # x : 2
134
- # }
135
- # c : 1
136
- # }
127
+ # An implementation may provide options to override this default behavior for
128
+ # repeated and message fields.
137
129
  #
138
130
  # In order to reset a field's value to the default, the field must
139
131
  # be in the mask and set to the default value in the provided resource.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -64,11 +64,11 @@ module Google
64
64
  ].freeze
65
65
 
66
66
 
67
- USER_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
68
- "users/{user}"
67
+ FINGERPRINT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
68
+ "users/{user}/sshPublicKeys/{fingerprint}"
69
69
  )
70
70
 
71
- private_constant :USER_PATH_TEMPLATE
71
+ private_constant :FINGERPRINT_PATH_TEMPLATE
72
72
 
73
73
  PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
74
74
  "users/{user}/projects/{project}"
@@ -76,18 +76,20 @@ module Google
76
76
 
77
77
  private_constant :PROJECT_PATH_TEMPLATE
78
78
 
79
- FINGERPRINT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
80
- "users/{user}/sshPublicKeys/{fingerprint}"
79
+ USER_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
80
+ "users/{user}"
81
81
  )
82
82
 
83
- private_constant :FINGERPRINT_PATH_TEMPLATE
83
+ private_constant :USER_PATH_TEMPLATE
84
84
 
85
- # Returns a fully-qualified user resource name string.
85
+ # Returns a fully-qualified fingerprint resource name string.
86
86
  # @param user [String]
87
+ # @param fingerprint [String]
87
88
  # @return [String]
88
- def self.user_path user
89
- USER_PATH_TEMPLATE.render(
90
- :"user" => user
89
+ def self.fingerprint_path user, fingerprint
90
+ FINGERPRINT_PATH_TEMPLATE.render(
91
+ :"user" => user,
92
+ :"fingerprint" => fingerprint
91
93
  )
92
94
  end
93
95
 
@@ -102,14 +104,12 @@ module Google
102
104
  )
103
105
  end
104
106
 
105
- # Returns a fully-qualified fingerprint resource name string.
107
+ # Returns a fully-qualified user resource name string.
106
108
  # @param user [String]
107
- # @param fingerprint [String]
108
109
  # @return [String]
109
- def self.fingerprint_path user, fingerprint
110
- FINGERPRINT_PATH_TEMPLATE.render(
111
- :"user" => user,
112
- :"fingerprint" => fingerprint
110
+ def self.user_path user
111
+ USER_PATH_TEMPLATE.render(
112
+ :"user" => user
113
113
  )
114
114
  end
115
115
 
@@ -218,32 +218,50 @@ module Google
218
218
  @delete_posix_account = Google::Gax.create_api_call(
219
219
  @os_login_service_stub.method(:delete_posix_account),
220
220
  defaults["delete_posix_account"],
221
- exception_transformer: exception_transformer
221
+ exception_transformer: exception_transformer,
222
+ params_extractor: proc do |request|
223
+ {'name' => request.name}
224
+ end
222
225
  )
223
226
  @delete_ssh_public_key = Google::Gax.create_api_call(
224
227
  @os_login_service_stub.method(:delete_ssh_public_key),
225
228
  defaults["delete_ssh_public_key"],
226
- exception_transformer: exception_transformer
229
+ exception_transformer: exception_transformer,
230
+ params_extractor: proc do |request|
231
+ {'name' => request.name}
232
+ end
227
233
  )
228
234
  @get_login_profile = Google::Gax.create_api_call(
229
235
  @os_login_service_stub.method(:get_login_profile),
230
236
  defaults["get_login_profile"],
231
- exception_transformer: exception_transformer
237
+ exception_transformer: exception_transformer,
238
+ params_extractor: proc do |request|
239
+ {'name' => request.name}
240
+ end
232
241
  )
233
242
  @get_ssh_public_key = Google::Gax.create_api_call(
234
243
  @os_login_service_stub.method(:get_ssh_public_key),
235
244
  defaults["get_ssh_public_key"],
236
- exception_transformer: exception_transformer
245
+ exception_transformer: exception_transformer,
246
+ params_extractor: proc do |request|
247
+ {'name' => request.name}
248
+ end
237
249
  )
238
250
  @import_ssh_public_key = Google::Gax.create_api_call(
239
251
  @os_login_service_stub.method(:import_ssh_public_key),
240
252
  defaults["import_ssh_public_key"],
241
- exception_transformer: exception_transformer
253
+ exception_transformer: exception_transformer,
254
+ params_extractor: proc do |request|
255
+ {'parent' => request.parent}
256
+ end
242
257
  )
243
258
  @update_ssh_public_key = Google::Gax.create_api_call(
244
259
  @os_login_service_stub.method(:update_ssh_public_key),
245
260
  defaults["update_ssh_public_key"],
246
- exception_transformer: exception_transformer
261
+ exception_transformer: exception_transformer,
262
+ params_extractor: proc do |request|
263
+ {'name' => request.name}
264
+ end
247
265
  )
248
266
  end
249
267
 
@@ -265,9 +283,9 @@ module Google
265
283
  # @example
266
284
  # require "google/cloud/os_login"
267
285
  #
268
- # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
286
+ # os_login_client = Google::Cloud::OsLogin.new(version: :v1)
269
287
  # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.project_path("[USER]", "[PROJECT]")
270
- # os_login_service_client.delete_posix_account(formatted_name)
288
+ # os_login_client.delete_posix_account(formatted_name)
271
289
 
272
290
  def delete_posix_account \
273
291
  name,
@@ -297,9 +315,9 @@ module Google
297
315
  # @example
298
316
  # require "google/cloud/os_login"
299
317
  #
300
- # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
318
+ # os_login_client = Google::Cloud::OsLogin.new(version: :v1)
301
319
  # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.fingerprint_path("[USER]", "[FINGERPRINT]")
302
- # os_login_service_client.delete_ssh_public_key(formatted_name)
320
+ # os_login_client.delete_ssh_public_key(formatted_name)
303
321
 
304
322
  def delete_ssh_public_key \
305
323
  name,
@@ -329,9 +347,9 @@ module Google
329
347
  # @example
330
348
  # require "google/cloud/os_login"
331
349
  #
332
- # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
350
+ # os_login_client = Google::Cloud::OsLogin.new(version: :v1)
333
351
  # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.user_path("[USER]")
334
- # response = os_login_service_client.get_login_profile(formatted_name)
352
+ # response = os_login_client.get_login_profile(formatted_name)
335
353
 
336
354
  def get_login_profile \
337
355
  name,
@@ -361,9 +379,9 @@ module Google
361
379
  # @example
362
380
  # require "google/cloud/os_login"
363
381
  #
364
- # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
382
+ # os_login_client = Google::Cloud::OsLogin.new(version: :v1)
365
383
  # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.fingerprint_path("[USER]", "[FINGERPRINT]")
366
- # response = os_login_service_client.get_ssh_public_key(formatted_name)
384
+ # response = os_login_client.get_ssh_public_key(formatted_name)
367
385
 
368
386
  def get_ssh_public_key \
369
387
  name,
@@ -399,12 +417,12 @@ module Google
399
417
  # @example
400
418
  # require "google/cloud/os_login"
401
419
  #
402
- # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
420
+ # os_login_client = Google::Cloud::OsLogin.new(version: :v1)
403
421
  # formatted_parent = Google::Cloud::OsLogin::V1::OsLoginServiceClient.user_path("[USER]")
404
422
  #
405
423
  # # TODO: Initialize `ssh_public_key`:
406
424
  # ssh_public_key = {}
407
- # response = os_login_service_client.import_ssh_public_key(formatted_parent, ssh_public_key)
425
+ # response = os_login_client.import_ssh_public_key(formatted_parent, ssh_public_key)
408
426
 
409
427
  def import_ssh_public_key \
410
428
  parent,
@@ -447,12 +465,12 @@ module Google
447
465
  # @example
448
466
  # require "google/cloud/os_login"
449
467
  #
450
- # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
468
+ # os_login_client = Google::Cloud::OsLogin.new(version: :v1)
451
469
  # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.fingerprint_path("[USER]", "[FINGERPRINT]")
452
470
  #
453
471
  # # TODO: Initialize `ssh_public_key`:
454
472
  # ssh_public_key = {}
455
- # response = os_login_service_client.update_ssh_public_key(formatted_name, ssh_public_key)
473
+ # response = os_login_client.update_ssh_public_key(formatted_name, ssh_public_key)
456
474
 
457
475
  def update_ssh_public_key \
458
476
  name,
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -83,57 +83,49 @@ module Google
83
83
  # describe the updated values, the API ignores the values of all
84
84
  # fields not covered by the mask.
85
85
  #
86
- # If a repeated field is specified for an update operation, the existing
87
- # repeated values in the target resource will be overwritten by the new values.
88
- # Note that a repeated field is only allowed in the last position of a `paths`
89
- # string.
86
+ # If a repeated field is specified for an update operation, new values will
87
+ # be appended to the existing repeated field in the target resource. Note that
88
+ # a repeated field is only allowed in the last position of a `paths` string.
90
89
  #
91
90
  # If a sub-message is specified in the last position of the field mask for an
92
- # update operation, then the existing sub-message in the target resource is
93
- # overwritten. Given the target message:
91
+ # update operation, then new value will be merged into the existing sub-message
92
+ # in the target resource.
93
+ #
94
+ # For example, given the target message:
94
95
  #
95
96
  # f {
96
97
  # b {
97
- # d : 1
98
- # x : 2
98
+ # d: 1
99
+ # x: 2
99
100
  # }
100
- # c : 1
101
+ # c: [1]
101
102
  # }
102
103
  #
103
104
  # And an update message:
104
105
  #
105
106
  # f {
106
107
  # b {
107
- # d : 10
108
+ # d: 10
108
109
  # }
110
+ # c: [2]
109
111
  # }
110
112
  #
111
113
  # then if the field mask is:
112
114
  #
113
- # paths: "f.b"
115
+ # paths: ["f.b", "f.c"]
114
116
  #
115
117
  # then the result will be:
116
118
  #
117
119
  # f {
118
120
  # b {
119
- # d : 10
121
+ # d: 10
122
+ # x: 2
120
123
  # }
121
- # c : 1
124
+ # c: [1, 2]
122
125
  # }
123
126
  #
124
- # However, if the update mask was:
125
- #
126
- # paths: "f.b.d"
127
- #
128
- # then the result would be:
129
- #
130
- # f {
131
- # b {
132
- # d : 10
133
- # x : 2
134
- # }
135
- # c : 1
136
- # }
127
+ # An implementation may provide options to override this default behavior for
128
+ # repeated and message fields.
137
129
  #
138
130
  # In order to reset a field's value to the default, the field must
139
131
  # be in the mask and set to the default value in the provided resource.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -64,11 +64,11 @@ module Google
64
64
  ].freeze
65
65
 
66
66
 
67
- USER_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
68
- "users/{user}"
67
+ FINGERPRINT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
68
+ "users/{user}/sshPublicKeys/{fingerprint}"
69
69
  )
70
70
 
71
- private_constant :USER_PATH_TEMPLATE
71
+ private_constant :FINGERPRINT_PATH_TEMPLATE
72
72
 
73
73
  PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
74
74
  "users/{user}/projects/{project}"
@@ -76,18 +76,20 @@ module Google
76
76
 
77
77
  private_constant :PROJECT_PATH_TEMPLATE
78
78
 
79
- FINGERPRINT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
80
- "users/{user}/sshPublicKeys/{fingerprint}"
79
+ USER_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
80
+ "users/{user}"
81
81
  )
82
82
 
83
- private_constant :FINGERPRINT_PATH_TEMPLATE
83
+ private_constant :USER_PATH_TEMPLATE
84
84
 
85
- # Returns a fully-qualified user resource name string.
85
+ # Returns a fully-qualified fingerprint resource name string.
86
86
  # @param user [String]
87
+ # @param fingerprint [String]
87
88
  # @return [String]
88
- def self.user_path user
89
- USER_PATH_TEMPLATE.render(
90
- :"user" => user
89
+ def self.fingerprint_path user, fingerprint
90
+ FINGERPRINT_PATH_TEMPLATE.render(
91
+ :"user" => user,
92
+ :"fingerprint" => fingerprint
91
93
  )
92
94
  end
93
95
 
@@ -102,14 +104,12 @@ module Google
102
104
  )
103
105
  end
104
106
 
105
- # Returns a fully-qualified fingerprint resource name string.
107
+ # Returns a fully-qualified user resource name string.
106
108
  # @param user [String]
107
- # @param fingerprint [String]
108
109
  # @return [String]
109
- def self.fingerprint_path user, fingerprint
110
- FINGERPRINT_PATH_TEMPLATE.render(
111
- :"user" => user,
112
- :"fingerprint" => fingerprint
110
+ def self.user_path user
111
+ USER_PATH_TEMPLATE.render(
112
+ :"user" => user
113
113
  )
114
114
  end
115
115
 
@@ -218,32 +218,50 @@ module Google
218
218
  @delete_posix_account = Google::Gax.create_api_call(
219
219
  @os_login_service_stub.method(:delete_posix_account),
220
220
  defaults["delete_posix_account"],
221
- exception_transformer: exception_transformer
221
+ exception_transformer: exception_transformer,
222
+ params_extractor: proc do |request|
223
+ {'name' => request.name}
224
+ end
222
225
  )
223
226
  @delete_ssh_public_key = Google::Gax.create_api_call(
224
227
  @os_login_service_stub.method(:delete_ssh_public_key),
225
228
  defaults["delete_ssh_public_key"],
226
- exception_transformer: exception_transformer
229
+ exception_transformer: exception_transformer,
230
+ params_extractor: proc do |request|
231
+ {'name' => request.name}
232
+ end
227
233
  )
228
234
  @get_login_profile = Google::Gax.create_api_call(
229
235
  @os_login_service_stub.method(:get_login_profile),
230
236
  defaults["get_login_profile"],
231
- exception_transformer: exception_transformer
237
+ exception_transformer: exception_transformer,
238
+ params_extractor: proc do |request|
239
+ {'name' => request.name}
240
+ end
232
241
  )
233
242
  @get_ssh_public_key = Google::Gax.create_api_call(
234
243
  @os_login_service_stub.method(:get_ssh_public_key),
235
244
  defaults["get_ssh_public_key"],
236
- exception_transformer: exception_transformer
245
+ exception_transformer: exception_transformer,
246
+ params_extractor: proc do |request|
247
+ {'name' => request.name}
248
+ end
237
249
  )
238
250
  @import_ssh_public_key = Google::Gax.create_api_call(
239
251
  @os_login_service_stub.method(:import_ssh_public_key),
240
252
  defaults["import_ssh_public_key"],
241
- exception_transformer: exception_transformer
253
+ exception_transformer: exception_transformer,
254
+ params_extractor: proc do |request|
255
+ {'parent' => request.parent}
256
+ end
242
257
  )
243
258
  @update_ssh_public_key = Google::Gax.create_api_call(
244
259
  @os_login_service_stub.method(:update_ssh_public_key),
245
260
  defaults["update_ssh_public_key"],
246
- exception_transformer: exception_transformer
261
+ exception_transformer: exception_transformer,
262
+ params_extractor: proc do |request|
263
+ {'name' => request.name}
264
+ end
247
265
  )
248
266
  end
249
267
 
@@ -265,9 +283,9 @@ module Google
265
283
  # @example
266
284
  # require "google/cloud/os_login"
267
285
  #
268
- # os_login_service_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
286
+ # os_login_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
269
287
  # formatted_name = Google::Cloud::OsLogin::V1beta::OsLoginServiceClient.project_path("[USER]", "[PROJECT]")
270
- # os_login_service_client.delete_posix_account(formatted_name)
288
+ # os_login_client.delete_posix_account(formatted_name)
271
289
 
272
290
  def delete_posix_account \
273
291
  name,
@@ -297,9 +315,9 @@ module Google
297
315
  # @example
298
316
  # require "google/cloud/os_login"
299
317
  #
300
- # os_login_service_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
318
+ # os_login_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
301
319
  # formatted_name = Google::Cloud::OsLogin::V1beta::OsLoginServiceClient.fingerprint_path("[USER]", "[FINGERPRINT]")
302
- # os_login_service_client.delete_ssh_public_key(formatted_name)
320
+ # os_login_client.delete_ssh_public_key(formatted_name)
303
321
 
304
322
  def delete_ssh_public_key \
305
323
  name,
@@ -329,9 +347,9 @@ module Google
329
347
  # @example
330
348
  # require "google/cloud/os_login"
331
349
  #
332
- # os_login_service_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
350
+ # os_login_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
333
351
  # formatted_name = Google::Cloud::OsLogin::V1beta::OsLoginServiceClient.user_path("[USER]")
334
- # response = os_login_service_client.get_login_profile(formatted_name)
352
+ # response = os_login_client.get_login_profile(formatted_name)
335
353
 
336
354
  def get_login_profile \
337
355
  name,
@@ -361,9 +379,9 @@ module Google
361
379
  # @example
362
380
  # require "google/cloud/os_login"
363
381
  #
364
- # os_login_service_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
382
+ # os_login_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
365
383
  # formatted_name = Google::Cloud::OsLogin::V1beta::OsLoginServiceClient.fingerprint_path("[USER]", "[FINGERPRINT]")
366
- # response = os_login_service_client.get_ssh_public_key(formatted_name)
384
+ # response = os_login_client.get_ssh_public_key(formatted_name)
367
385
 
368
386
  def get_ssh_public_key \
369
387
  name,
@@ -399,12 +417,12 @@ module Google
399
417
  # @example
400
418
  # require "google/cloud/os_login"
401
419
  #
402
- # os_login_service_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
420
+ # os_login_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
403
421
  # formatted_parent = Google::Cloud::OsLogin::V1beta::OsLoginServiceClient.user_path("[USER]")
404
422
  #
405
423
  # # TODO: Initialize `ssh_public_key`:
406
424
  # ssh_public_key = {}
407
- # response = os_login_service_client.import_ssh_public_key(formatted_parent, ssh_public_key)
425
+ # response = os_login_client.import_ssh_public_key(formatted_parent, ssh_public_key)
408
426
 
409
427
  def import_ssh_public_key \
410
428
  parent,
@@ -447,12 +465,12 @@ module Google
447
465
  # @example
448
466
  # require "google/cloud/os_login"
449
467
  #
450
- # os_login_service_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
468
+ # os_login_client = Google::Cloud::OsLogin::V1beta.new(version: :v1beta)
451
469
  # formatted_name = Google::Cloud::OsLogin::V1beta::OsLoginServiceClient.fingerprint_path("[USER]", "[FINGERPRINT]")
452
470
  #
453
471
  # # TODO: Initialize `ssh_public_key`:
454
472
  # ssh_public_key = {}
455
- # response = os_login_service_client.update_ssh_public_key(formatted_name, ssh_public_key)
473
+ # response = os_login_client.update_ssh_public_key(formatted_name, ssh_public_key)
456
474
 
457
475
  def update_ssh_public_key \
458
476
  name,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-os_login
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-21 00:00:00.000000000 Z
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-gax
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.50.0
61
+ version: 0.64.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.50.0
68
+ version: 0.64.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +102,7 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".yardopts"
105
+ - AUTHENTICATION.md
105
106
  - LICENSE
106
107
  - README.md
107
108
  - lib/google/cloud/os_login.rb
@@ -146,8 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  - !ruby/object:Gem::Version
147
148
  version: '0'
148
149
  requirements: []
149
- rubyforge_project:
150
- rubygems_version: 2.7.7
150
+ rubygems_version: 3.0.3
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: API Client library for Google Cloud OS Login API