google-cloud-os_login 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +39 -2
  4. data/lib/google/cloud/os_login.rb +34 -4
  5. data/lib/google/cloud/os_login/v1.rb +134 -0
  6. data/lib/google/cloud/os_login/v1/credentials.rb +43 -0
  7. data/lib/google/cloud/os_login/v1/doc/google/cloud/oslogin/common/common.rb +66 -0
  8. data/lib/google/cloud/os_login/v1/doc/google/cloud/oslogin/v1/oslogin.rb +111 -0
  9. data/lib/google/cloud/os_login/v1/doc/google/protobuf/empty.rb +28 -0
  10. data/lib/google/cloud/os_login/v1/doc/google/protobuf/field_mask.rb +223 -0
  11. data/lib/google/cloud/os_login/v1/doc/overview.rb +79 -0
  12. data/lib/google/cloud/os_login/v1/os_login_service_client.rb +473 -0
  13. data/lib/google/cloud/os_login/v1/os_login_service_client_config.json +56 -0
  14. data/lib/google/cloud/os_login/v1beta.rb +62 -28
  15. data/lib/google/cloud/os_login/v1beta/credentials.rb +43 -0
  16. data/lib/google/cloud/os_login/v1beta/doc/google/cloud/oslogin/common/common.rb +66 -0
  17. data/lib/google/cloud/os_login/v1beta/doc/google/cloud/oslogin/v1beta/oslogin.rb +2 -2
  18. data/lib/google/cloud/os_login/v1beta/doc/google/protobuf/empty.rb +28 -0
  19. data/lib/google/cloud/os_login/v1beta/doc/google/protobuf/field_mask.rb +1 -1
  20. data/lib/google/cloud/os_login/v1beta/doc/overview.rb +27 -2
  21. data/lib/google/cloud/os_login/v1beta/os_login_service_client.rb +82 -38
  22. data/lib/google/cloud/oslogin/{common_pb.rb → common/common_pb.rb} +1 -1
  23. data/lib/google/cloud/oslogin/v1/oslogin_pb.rb +59 -0
  24. data/lib/google/cloud/oslogin/v1/oslogin_services_pb.rb +62 -0
  25. data/lib/google/cloud/oslogin/v1beta/oslogin_pb.rb +1 -1
  26. metadata +53 -12
  27. data/lib/google/cloud/os_login/credentials.rb +0 -33
@@ -0,0 +1,28 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Protobuf
17
+ # A generic empty message that you can re-use to avoid defining duplicated
18
+ # empty messages in your APIs. A typical example is to use it as the request
19
+ # or the response type of an API method. For instance:
20
+ #
21
+ # service Foo {
22
+ # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
23
+ # }
24
+ #
25
+ # The JSON representation for +Empty+ is empty JSON object +{}+.
26
+ class Empty; end
27
+ end
28
+ end
@@ -0,0 +1,223 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Protobuf
17
+ # +FieldMask+ represents a set of symbolic field paths, for example:
18
+ #
19
+ # paths: "f.a"
20
+ # paths: "f.b.d"
21
+ #
22
+ # Here +f+ represents a field in some root message, +a+ and +b+
23
+ # fields in the message found in +f+, and +d+ a field found in the
24
+ # message in +f.b+.
25
+ #
26
+ # Field masks are used to specify a subset of fields that should be
27
+ # returned by a get operation or modified by an update operation.
28
+ # Field masks also have a custom JSON encoding (see below).
29
+ #
30
+ # = Field Masks in Projections
31
+ #
32
+ # When used in the context of a projection, a response message or
33
+ # sub-message is filtered by the API to only contain those fields as
34
+ # specified in the mask. For example, if the mask in the previous
35
+ # example is applied to a response message as follows:
36
+ #
37
+ # f {
38
+ # a : 22
39
+ # b {
40
+ # d : 1
41
+ # x : 2
42
+ # }
43
+ # y : 13
44
+ # }
45
+ # z: 8
46
+ #
47
+ # The result will not contain specific values for fields x,y and z
48
+ # (their value will be set to the default, and omitted in proto text
49
+ # output):
50
+ #
51
+ #
52
+ # f {
53
+ # a : 22
54
+ # b {
55
+ # d : 1
56
+ # }
57
+ # }
58
+ #
59
+ # A repeated field is not allowed except at the last position of a
60
+ # paths string.
61
+ #
62
+ # If a FieldMask object is not present in a get operation, the
63
+ # operation applies to all fields (as if a FieldMask of all fields
64
+ # had been specified).
65
+ #
66
+ # Note that a field mask does not necessarily apply to the
67
+ # top-level response message. In case of a REST get operation, the
68
+ # field mask applies directly to the response, but in case of a REST
69
+ # list operation, the mask instead applies to each individual message
70
+ # in the returned resource list. In case of a REST custom method,
71
+ # other definitions may be used. Where the mask applies will be
72
+ # clearly documented together with its declaration in the API. In
73
+ # any case, the effect on the returned resource/resources is required
74
+ # behavior for APIs.
75
+ #
76
+ # = Field Masks in Update Operations
77
+ #
78
+ # A field mask in update operations specifies which fields of the
79
+ # targeted resource are going to be updated. The API is required
80
+ # to only change the values of the fields as specified in the mask
81
+ # and leave the others untouched. If a resource is passed in to
82
+ # describe the updated values, the API ignores the values of all
83
+ # fields not covered by the mask.
84
+ #
85
+ # If a repeated field is specified for an update operation, the existing
86
+ # repeated values in the target resource will be overwritten by the new values.
87
+ # Note that a repeated field is only allowed in the last position of a +paths+
88
+ # string.
89
+ #
90
+ # If a sub-message is specified in the last position of the field mask for an
91
+ # update operation, then the existing sub-message in the target resource is
92
+ # overwritten. Given the target message:
93
+ #
94
+ # f {
95
+ # b {
96
+ # d : 1
97
+ # x : 2
98
+ # }
99
+ # c : 1
100
+ # }
101
+ #
102
+ # And an update message:
103
+ #
104
+ # f {
105
+ # b {
106
+ # d : 10
107
+ # }
108
+ # }
109
+ #
110
+ # then if the field mask is:
111
+ #
112
+ # paths: "f.b"
113
+ #
114
+ # then the result will be:
115
+ #
116
+ # f {
117
+ # b {
118
+ # d : 10
119
+ # }
120
+ # c : 1
121
+ # }
122
+ #
123
+ # However, if the update mask was:
124
+ #
125
+ # paths: "f.b.d"
126
+ #
127
+ # then the result would be:
128
+ #
129
+ # f {
130
+ # b {
131
+ # d : 10
132
+ # x : 2
133
+ # }
134
+ # c : 1
135
+ # }
136
+ #
137
+ # In order to reset a field's value to the default, the field must
138
+ # be in the mask and set to the default value in the provided resource.
139
+ # Hence, in order to reset all fields of a resource, provide a default
140
+ # instance of the resource and set all fields in the mask, or do
141
+ # not provide a mask as described below.
142
+ #
143
+ # If a field mask is not present on update, the operation applies to
144
+ # all fields (as if a field mask of all fields has been specified).
145
+ # Note that in the presence of schema evolution, this may mean that
146
+ # fields the client does not know and has therefore not filled into
147
+ # the request will be reset to their default. If this is unwanted
148
+ # behavior, a specific service may require a client to always specify
149
+ # a field mask, producing an error if not.
150
+ #
151
+ # As with get operations, the location of the resource which
152
+ # describes the updated values in the request message depends on the
153
+ # operation kind. In any case, the effect of the field mask is
154
+ # required to be honored by the API.
155
+ #
156
+ # == Considerations for HTTP REST
157
+ #
158
+ # The HTTP kind of an update operation which uses a field mask must
159
+ # be set to PATCH instead of PUT in order to satisfy HTTP semantics
160
+ # (PUT must only be used for full updates).
161
+ #
162
+ # = JSON Encoding of Field Masks
163
+ #
164
+ # In JSON, a field mask is encoded as a single string where paths are
165
+ # separated by a comma. Fields name in each path are converted
166
+ # to/from lower-camel naming conventions.
167
+ #
168
+ # As an example, consider the following message declarations:
169
+ #
170
+ # message Profile {
171
+ # User user = 1;
172
+ # Photo photo = 2;
173
+ # }
174
+ # message User {
175
+ # string display_name = 1;
176
+ # string address = 2;
177
+ # }
178
+ #
179
+ # In proto a field mask for +Profile+ may look as such:
180
+ #
181
+ # mask {
182
+ # paths: "user.display_name"
183
+ # paths: "photo"
184
+ # }
185
+ #
186
+ # In JSON, the same mask is represented as below:
187
+ #
188
+ # {
189
+ # mask: "user.displayName,photo"
190
+ # }
191
+ #
192
+ # = Field Masks and Oneof Fields
193
+ #
194
+ # Field masks treat fields in oneofs just as regular fields. Consider the
195
+ # following message:
196
+ #
197
+ # message SampleMessage {
198
+ # oneof test_oneof {
199
+ # string name = 4;
200
+ # SubMessage sub_message = 9;
201
+ # }
202
+ # }
203
+ #
204
+ # The field mask can be:
205
+ #
206
+ # mask {
207
+ # paths: "name"
208
+ # }
209
+ #
210
+ # Or:
211
+ #
212
+ # mask {
213
+ # paths: "sub_message"
214
+ # }
215
+ #
216
+ # Note that oneof type names ("test_oneof" in this case) cannot be used in
217
+ # paths.
218
+ # @!attribute [rw] paths
219
+ # @return [Array<String>]
220
+ # The set of field mask paths.
221
+ class FieldMask; end
222
+ end
223
+ end
@@ -0,0 +1,79 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Cloud
17
+ # rubocop:disable LineLength
18
+
19
+ ##
20
+ # # Ruby Client for Google Cloud OS Login API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
+ #
22
+ # [Google Cloud OS Login API][Product Documentation]:
23
+ # Manages OS login configuration for Google account users.
24
+ # - [Product Documentation][]
25
+ #
26
+ # ## Quick Start
27
+ # In order to use this library, you first need to go through the following
28
+ # steps:
29
+ #
30
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
31
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
32
+ # 3. [Enable the Google Cloud OS Login API.](https://console.cloud.google.com/apis/library/oslogin.googleapis.com)
33
+ # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
34
+ #
35
+ # ### Installation
36
+ # ```
37
+ # $ gem install google-cloud-os_login
38
+ # ```
39
+ #
40
+ # ### Next Steps
41
+ # - Read the [Google Cloud OS Login API Product documentation][Product Documentation]
42
+ # to learn more about the product and see How-to Guides.
43
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
44
+ # to see the full list of Cloud APIs that we cover.
45
+ #
46
+ # [Product Documentation]: https://cloud.google.com/compute/docs/oslogin/rest/
47
+ #
48
+ # ## Enabling Logging
49
+ #
50
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
51
+ # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
52
+ # or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
53
+ # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
54
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
55
+ #
56
+ # Configuring a Ruby stdlib logger:
57
+ #
58
+ # ```ruby
59
+ # require "logger"
60
+ #
61
+ # module MyLogger
62
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
63
+ # def logger
64
+ # LOGGER
65
+ # end
66
+ # end
67
+ #
68
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
69
+ # module GRPC
70
+ # extend MyLogger
71
+ # end
72
+ # ```
73
+ #
74
+ module OsLogin
75
+ module V1
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,473 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # EDITING INSTRUCTIONS
16
+ # This file was generated from the file
17
+ # https://github.com/googleapis/googleapis/blob/master/google/cloud/oslogin/v1/oslogin.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+
22
+ require "json"
23
+ require "pathname"
24
+
25
+ require "google/gax"
26
+
27
+ require "google/cloud/oslogin/v1/oslogin_pb"
28
+ require "google/cloud/os_login/v1/credentials"
29
+
30
+ module Google
31
+ module Cloud
32
+ module OsLogin
33
+ module V1
34
+ # Cloud OS Login API
35
+ #
36
+ # The Cloud OS Login API allows you to manage users and their associated SSH
37
+ # public keys for logging into virtual machines on Google Cloud Platform.
38
+ #
39
+ # @!attribute [r] os_login_service_stub
40
+ # @return [Google::Cloud::Oslogin::V1::OsLoginService::Stub]
41
+ class OsLoginServiceClient
42
+ attr_reader :os_login_service_stub
43
+
44
+ # The default address of the service.
45
+ SERVICE_ADDRESS = "oslogin.googleapis.com".freeze
46
+
47
+ # The default port of the service.
48
+ DEFAULT_SERVICE_PORT = 443
49
+
50
+ # The default set of gRPC interceptors.
51
+ GRPC_INTERCEPTORS = []
52
+
53
+ DEFAULT_TIMEOUT = 30
54
+
55
+ # The scopes needed to make gRPC calls to all of the methods defined in
56
+ # this service.
57
+ ALL_SCOPES = [
58
+ "https://www.googleapis.com/auth/cloud-platform",
59
+ "https://www.googleapis.com/auth/cloud-platform.read-only",
60
+ "https://www.googleapis.com/auth/compute",
61
+ "https://www.googleapis.com/auth/compute.readonly"
62
+ ].freeze
63
+
64
+
65
+ USER_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
66
+ "users/{user}"
67
+ )
68
+
69
+ private_constant :USER_PATH_TEMPLATE
70
+
71
+ PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
72
+ "users/{user}/projects/{project}"
73
+ )
74
+
75
+ private_constant :PROJECT_PATH_TEMPLATE
76
+
77
+ FINGERPRINT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
78
+ "users/{user}/sshPublicKeys/{fingerprint}"
79
+ )
80
+
81
+ private_constant :FINGERPRINT_PATH_TEMPLATE
82
+
83
+ # Returns a fully-qualified user resource name string.
84
+ # @param user [String]
85
+ # @return [String]
86
+ def self.user_path user
87
+ USER_PATH_TEMPLATE.render(
88
+ :"user" => user
89
+ )
90
+ end
91
+
92
+ # Returns a fully-qualified project resource name string.
93
+ # @param user [String]
94
+ # @param project [String]
95
+ # @return [String]
96
+ def self.project_path user, project
97
+ PROJECT_PATH_TEMPLATE.render(
98
+ :"user" => user,
99
+ :"project" => project
100
+ )
101
+ end
102
+
103
+ # Returns a fully-qualified fingerprint resource name string.
104
+ # @param user [String]
105
+ # @param fingerprint [String]
106
+ # @return [String]
107
+ def self.fingerprint_path user, fingerprint
108
+ FINGERPRINT_PATH_TEMPLATE.render(
109
+ :"user" => user,
110
+ :"fingerprint" => fingerprint
111
+ )
112
+ end
113
+
114
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
115
+ # Provides the means for authenticating requests made by the client. This parameter can
116
+ # be many types.
117
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
118
+ # authenticating requests made by this client.
119
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
120
+ # credentials for this client.
121
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
122
+ # credentials for this client.
123
+ # A `GRPC::Core::Channel` will be used to make calls through.
124
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
125
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
126
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
127
+ # metadata for requests, generally, to give OAuth credentials.
128
+ # @param scopes [Array<String>]
129
+ # The OAuth scopes for this service. This parameter is ignored if
130
+ # an updater_proc is supplied.
131
+ # @param client_config [Hash]
132
+ # A Hash for call options for each method. See
133
+ # Google::Gax#construct_settings for the structure of
134
+ # this data. Falls back to the default config if not specified
135
+ # or the specified config is missing data points.
136
+ # @param timeout [Numeric]
137
+ # The default timeout, in seconds, for calls made through this client.
138
+ # @param metadata [Hash]
139
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
140
+ # @param exception_transformer [Proc]
141
+ # An optional proc that intercepts any exceptions raised during an API call to inject
142
+ # custom error handling.
143
+ def initialize \
144
+ credentials: nil,
145
+ scopes: ALL_SCOPES,
146
+ client_config: {},
147
+ timeout: DEFAULT_TIMEOUT,
148
+ metadata: nil,
149
+ exception_transformer: nil,
150
+ lib_name: nil,
151
+ lib_version: ""
152
+ # These require statements are intentionally placed here to initialize
153
+ # the gRPC module only when it's required.
154
+ # See https://github.com/googleapis/toolkit/issues/446
155
+ require "google/gax/grpc"
156
+ require "google/cloud/oslogin/v1/oslogin_services_pb"
157
+
158
+ credentials ||= Google::Cloud::OsLogin::V1::Credentials.default
159
+
160
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
161
+ updater_proc = Google::Cloud::OsLogin::V1::Credentials.new(credentials).updater_proc
162
+ end
163
+ if credentials.is_a?(GRPC::Core::Channel)
164
+ channel = credentials
165
+ end
166
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
167
+ chan_creds = credentials
168
+ end
169
+ if credentials.is_a?(Proc)
170
+ updater_proc = credentials
171
+ end
172
+ if credentials.is_a?(Google::Auth::Credentials)
173
+ updater_proc = credentials.updater_proc
174
+ end
175
+
176
+ package_version = Gem.loaded_specs['google-cloud-os_login'].version.version
177
+
178
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
179
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
180
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
181
+ google_api_client << " grpc/#{GRPC::VERSION}"
182
+ google_api_client.freeze
183
+
184
+ headers = { :"x-goog-api-client" => google_api_client }
185
+ headers.merge!(metadata) unless metadata.nil?
186
+ client_config_file = Pathname.new(__dir__).join(
187
+ "os_login_service_client_config.json"
188
+ )
189
+ defaults = client_config_file.open do |f|
190
+ Google::Gax.construct_settings(
191
+ "google.cloud.oslogin.v1.OsLoginService",
192
+ JSON.parse(f.read),
193
+ client_config,
194
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
195
+ timeout,
196
+ errors: Google::Gax::Grpc::API_ERRORS,
197
+ metadata: headers
198
+ )
199
+ end
200
+
201
+ # Allow overriding the service path/port in subclasses.
202
+ service_path = self.class::SERVICE_ADDRESS
203
+ port = self.class::DEFAULT_SERVICE_PORT
204
+ interceptors = self.class::GRPC_INTERCEPTORS
205
+ @os_login_service_stub = Google::Gax::Grpc.create_stub(
206
+ service_path,
207
+ port,
208
+ chan_creds: chan_creds,
209
+ channel: channel,
210
+ updater_proc: updater_proc,
211
+ scopes: scopes,
212
+ interceptors: interceptors,
213
+ &Google::Cloud::Oslogin::V1::OsLoginService::Stub.method(:new)
214
+ )
215
+
216
+ @delete_posix_account = Google::Gax.create_api_call(
217
+ @os_login_service_stub.method(:delete_posix_account),
218
+ defaults["delete_posix_account"],
219
+ exception_transformer: exception_transformer
220
+ )
221
+ @delete_ssh_public_key = Google::Gax.create_api_call(
222
+ @os_login_service_stub.method(:delete_ssh_public_key),
223
+ defaults["delete_ssh_public_key"],
224
+ exception_transformer: exception_transformer
225
+ )
226
+ @get_login_profile = Google::Gax.create_api_call(
227
+ @os_login_service_stub.method(:get_login_profile),
228
+ defaults["get_login_profile"],
229
+ exception_transformer: exception_transformer
230
+ )
231
+ @get_ssh_public_key = Google::Gax.create_api_call(
232
+ @os_login_service_stub.method(:get_ssh_public_key),
233
+ defaults["get_ssh_public_key"],
234
+ exception_transformer: exception_transformer
235
+ )
236
+ @import_ssh_public_key = Google::Gax.create_api_call(
237
+ @os_login_service_stub.method(:import_ssh_public_key),
238
+ defaults["import_ssh_public_key"],
239
+ exception_transformer: exception_transformer
240
+ )
241
+ @update_ssh_public_key = Google::Gax.create_api_call(
242
+ @os_login_service_stub.method(:update_ssh_public_key),
243
+ defaults["update_ssh_public_key"],
244
+ exception_transformer: exception_transformer
245
+ )
246
+ end
247
+
248
+ # Service calls
249
+
250
+ # Deletes a POSIX account.
251
+ #
252
+ # @param name [String]
253
+ # A reference to the POSIX account to update. POSIX accounts are identified
254
+ # by the project ID they are associated with. A reference to the POSIX
255
+ # account is in format +users/{user}/projects/{project}+.
256
+ # @param options [Google::Gax::CallOptions]
257
+ # Overrides the default settings for this call, e.g, timeout,
258
+ # retries, etc.
259
+ # @yield [result, operation] Access the result along with the RPC operation
260
+ # @yieldparam result []
261
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
262
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
263
+ # @example
264
+ # require "google/cloud/os_login"
265
+ #
266
+ # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
267
+ # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.project_path("[USER]", "[PROJECT]")
268
+ # os_login_service_client.delete_posix_account(formatted_name)
269
+
270
+ def delete_posix_account \
271
+ name,
272
+ options: nil,
273
+ &block
274
+ req = {
275
+ name: name
276
+ }.delete_if { |_, v| v.nil? }
277
+ req = Google::Gax::to_proto(req, Google::Cloud::Oslogin::V1::DeletePosixAccountRequest)
278
+ @delete_posix_account.call(req, options, &block)
279
+ nil
280
+ end
281
+
282
+ # Deletes an SSH public key.
283
+ #
284
+ # @param name [String]
285
+ # The fingerprint of the public key to update. Public keys are identified by
286
+ # their SHA-256 fingerprint. The fingerprint of the public key is in format
287
+ # +users/{user}/sshPublicKeys/{fingerprint}+.
288
+ # @param options [Google::Gax::CallOptions]
289
+ # Overrides the default settings for this call, e.g, timeout,
290
+ # retries, etc.
291
+ # @yield [result, operation] Access the result along with the RPC operation
292
+ # @yieldparam result []
293
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
294
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
295
+ # @example
296
+ # require "google/cloud/os_login"
297
+ #
298
+ # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
299
+ # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.fingerprint_path("[USER]", "[FINGERPRINT]")
300
+ # os_login_service_client.delete_ssh_public_key(formatted_name)
301
+
302
+ def delete_ssh_public_key \
303
+ name,
304
+ options: nil,
305
+ &block
306
+ req = {
307
+ name: name
308
+ }.delete_if { |_, v| v.nil? }
309
+ req = Google::Gax::to_proto(req, Google::Cloud::Oslogin::V1::DeleteSshPublicKeyRequest)
310
+ @delete_ssh_public_key.call(req, options, &block)
311
+ nil
312
+ end
313
+
314
+ # Retrieves the profile information used for logging in to a virtual machine
315
+ # on Google Compute Engine.
316
+ #
317
+ # @param name [String]
318
+ # The unique ID for the user in format +users/{user}+.
319
+ # @param options [Google::Gax::CallOptions]
320
+ # Overrides the default settings for this call, e.g, timeout,
321
+ # retries, etc.
322
+ # @yield [result, operation] Access the result along with the RPC operation
323
+ # @yieldparam result [Google::Cloud::Oslogin::V1::LoginProfile]
324
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
325
+ # @return [Google::Cloud::Oslogin::V1::LoginProfile]
326
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
327
+ # @example
328
+ # require "google/cloud/os_login"
329
+ #
330
+ # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
331
+ # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.user_path("[USER]")
332
+ # response = os_login_service_client.get_login_profile(formatted_name)
333
+
334
+ def get_login_profile \
335
+ name,
336
+ options: nil,
337
+ &block
338
+ req = {
339
+ name: name
340
+ }.delete_if { |_, v| v.nil? }
341
+ req = Google::Gax::to_proto(req, Google::Cloud::Oslogin::V1::GetLoginProfileRequest)
342
+ @get_login_profile.call(req, options, &block)
343
+ end
344
+
345
+ # Retrieves an SSH public key.
346
+ #
347
+ # @param name [String]
348
+ # The fingerprint of the public key to retrieve. Public keys are identified
349
+ # by their SHA-256 fingerprint. The fingerprint of the public key is in
350
+ # format +users/{user}/sshPublicKeys/{fingerprint}+.
351
+ # @param options [Google::Gax::CallOptions]
352
+ # Overrides the default settings for this call, e.g, timeout,
353
+ # retries, etc.
354
+ # @yield [result, operation] Access the result along with the RPC operation
355
+ # @yieldparam result [Google::Cloud::Oslogin::Common::SshPublicKey]
356
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
357
+ # @return [Google::Cloud::Oslogin::Common::SshPublicKey]
358
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
359
+ # @example
360
+ # require "google/cloud/os_login"
361
+ #
362
+ # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
363
+ # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.fingerprint_path("[USER]", "[FINGERPRINT]")
364
+ # response = os_login_service_client.get_ssh_public_key(formatted_name)
365
+
366
+ def get_ssh_public_key \
367
+ name,
368
+ options: nil,
369
+ &block
370
+ req = {
371
+ name: name
372
+ }.delete_if { |_, v| v.nil? }
373
+ req = Google::Gax::to_proto(req, Google::Cloud::Oslogin::V1::GetSshPublicKeyRequest)
374
+ @get_ssh_public_key.call(req, options, &block)
375
+ end
376
+
377
+ # Adds an SSH public key and returns the profile information. Default POSIX
378
+ # account information is set when no username and UID exist as part of the
379
+ # login profile.
380
+ #
381
+ # @param parent [String]
382
+ # The unique ID for the user in format +users/{user}+.
383
+ # @param ssh_public_key [Google::Cloud::Oslogin::Common::SshPublicKey | Hash]
384
+ # The SSH public key and expiration time.
385
+ # A hash of the same form as `Google::Cloud::Oslogin::Common::SshPublicKey`
386
+ # can also be provided.
387
+ # @param project_id [String]
388
+ # The project ID of the Google Cloud Platform project.
389
+ # @param options [Google::Gax::CallOptions]
390
+ # Overrides the default settings for this call, e.g, timeout,
391
+ # retries, etc.
392
+ # @yield [result, operation] Access the result along with the RPC operation
393
+ # @yieldparam result [Google::Cloud::Oslogin::V1::ImportSshPublicKeyResponse]
394
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
395
+ # @return [Google::Cloud::Oslogin::V1::ImportSshPublicKeyResponse]
396
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
397
+ # @example
398
+ # require "google/cloud/os_login"
399
+ #
400
+ # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
401
+ # formatted_parent = Google::Cloud::OsLogin::V1::OsLoginServiceClient.user_path("[USER]")
402
+ #
403
+ # # TODO: Initialize +ssh_public_key+:
404
+ # ssh_public_key = {}
405
+ # response = os_login_service_client.import_ssh_public_key(formatted_parent, ssh_public_key)
406
+
407
+ def import_ssh_public_key \
408
+ parent,
409
+ ssh_public_key,
410
+ project_id: nil,
411
+ options: nil,
412
+ &block
413
+ req = {
414
+ parent: parent,
415
+ ssh_public_key: ssh_public_key,
416
+ project_id: project_id
417
+ }.delete_if { |_, v| v.nil? }
418
+ req = Google::Gax::to_proto(req, Google::Cloud::Oslogin::V1::ImportSshPublicKeyRequest)
419
+ @import_ssh_public_key.call(req, options, &block)
420
+ end
421
+
422
+ # Updates an SSH public key and returns the profile information. This method
423
+ # supports patch semantics.
424
+ #
425
+ # @param name [String]
426
+ # The fingerprint of the public key to update. Public keys are identified by
427
+ # their SHA-256 fingerprint. The fingerprint of the public key is in format
428
+ # +users/{user}/sshPublicKeys/{fingerprint}+.
429
+ # @param ssh_public_key [Google::Cloud::Oslogin::Common::SshPublicKey | Hash]
430
+ # The SSH public key and expiration time.
431
+ # A hash of the same form as `Google::Cloud::Oslogin::Common::SshPublicKey`
432
+ # can also be provided.
433
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
434
+ # Mask to control which fields get updated. Updates all if not present.
435
+ # A hash of the same form as `Google::Protobuf::FieldMask`
436
+ # can also be provided.
437
+ # @param options [Google::Gax::CallOptions]
438
+ # Overrides the default settings for this call, e.g, timeout,
439
+ # retries, etc.
440
+ # @yield [result, operation] Access the result along with the RPC operation
441
+ # @yieldparam result [Google::Cloud::Oslogin::Common::SshPublicKey]
442
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
443
+ # @return [Google::Cloud::Oslogin::Common::SshPublicKey]
444
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
445
+ # @example
446
+ # require "google/cloud/os_login"
447
+ #
448
+ # os_login_service_client = Google::Cloud::OsLogin.new(version: :v1)
449
+ # formatted_name = Google::Cloud::OsLogin::V1::OsLoginServiceClient.fingerprint_path("[USER]", "[FINGERPRINT]")
450
+ #
451
+ # # TODO: Initialize +ssh_public_key+:
452
+ # ssh_public_key = {}
453
+ # response = os_login_service_client.update_ssh_public_key(formatted_name, ssh_public_key)
454
+
455
+ def update_ssh_public_key \
456
+ name,
457
+ ssh_public_key,
458
+ update_mask: nil,
459
+ options: nil,
460
+ &block
461
+ req = {
462
+ name: name,
463
+ ssh_public_key: ssh_public_key,
464
+ update_mask: update_mask
465
+ }.delete_if { |_, v| v.nil? }
466
+ req = Google::Gax::to_proto(req, Google::Cloud::Oslogin::V1::UpdateSshPublicKeyRequest)
467
+ @update_ssh_public_key.call(req, options, &block)
468
+ end
469
+ end
470
+ end
471
+ end
472
+ end
473
+ end