Skip to content

Commit de74b58

Browse files
feat: [oslogin] added CreateSshPublicKey RPC (#8783)
* feat: added CreateSshPublicKey RPC PiperOrigin-RevId: 488460648 Source-Link: googleapis/googleapis@2360559 Source-Link: https://github.com/googleapis/googleapis-gen/commit/59576752785e41d49590c1ed00042827611f3438 Copy-Tag: eyJwIjoiamF2YS1vcy1sb2dpbi8uT3dsQm90LnlhbWwiLCJoIjoiNTk1NzY3NTI3ODVlNDFkNDk1OTBjMWVkMDAwNDI4Mjc2MTFmMzQzOCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent d50169d commit de74b58

File tree

20 files changed

+1997
-106
lines changed

20 files changed

+1997
-106
lines changed

java-os-login/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file:
1919
<dependency>
2020
<groupId>com.google.cloud</groupId>
2121
<artifactId>google-cloud-os-login</artifactId>
22-
<version>2.4.0</version>
22+
<version>2.5.0</version>
2323
</dependency>
2424
```
2525

2626
If you are using Gradle without BOM, add this to your dependencies:
2727

2828
```Groovy
29-
implementation 'com.google.cloud:google-cloud-os-login:2.4.0'
29+
implementation 'com.google.cloud:google-cloud-os-login:2.5.0'
3030
```
3131

3232
If you are using SBT, add this to your dependencies:
3333

3434
```Scala
35-
libraryDependencies += "com.google.cloud" % "google-cloud-os-login" % "2.4.0"
35+
libraryDependencies += "com.google.cloud" % "google-cloud-os-login" % "2.5.0"
3636
```
3737

3838
## Authentication
@@ -159,16 +159,16 @@ Java is a registered trademark of Oracle and/or its affiliates.
159159

160160
[product-docs]: https://cloud.google.com/compute/docs/oslogin/
161161
[javadocs]: https://cloud.google.com/java/docs/reference/google-cloud-os-login/latest/overview
162-
[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java7.svg
163-
[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java7.html
164-
[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8.svg
165-
[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8.html
166-
[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8-osx.svg
167-
[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8-osx.html
168-
[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8-win.svg
169-
[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8-win.html
170-
[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java11.svg
171-
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java11.html
162+
[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java7.svg
163+
[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java7.html
164+
[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8.svg
165+
[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8.html
166+
[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8-osx.svg
167+
[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8-osx.html
168+
[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8-win.svg
169+
[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8-win.html
170+
[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.svg
171+
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
172172
[stability-image]: https://img.shields.io/badge/stability-stable-green
173173
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-os-login.svg
174174
[maven-version-link]: https://search.maven.org/search?q=g:com.google.cloud%20AND%20a:google-cloud-os-login&core=gav
@@ -180,9 +180,9 @@ Java is a registered trademark of Oracle and/or its affiliates.
180180
[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects
181181
[cloud-sdk]: https://cloud.google.com/sdk/
182182
[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/main/troubleshooting/readme.md#troubleshooting
183-
[contributing]: https://github.com/googleapis/java-os-login/blob/main/CONTRIBUTING.md
184-
[code-of-conduct]: https://github.com/googleapis/java-os-login/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct
185-
[license]: https://github.com/googleapis/java-os-login/blob/main/LICENSE
183+
[contributing]: https://github.com/googleapis/google-cloud-java/blob/main/CONTRIBUTING.md
184+
[code-of-conduct]: https://github.com/googleapis/google-cloud-java/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct
185+
[license]: https://github.com/googleapis/google-cloud-java/blob/main/LICENSE
186186
[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing
187187
[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=oslogin.googleapis.com
188188
[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM

java-os-login/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceClient.java

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@
4444
* // - It may require specifying regional endpoints when creating the service client as shown in
4545
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
4646
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
47-
* ProjectName name = ProjectName.of("[USER]", "[PROJECT]");
48-
* osLoginServiceClient.deletePosixAccount(name);
47+
* UserName parent = UserName.of("[USER]");
48+
* OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build();
49+
* OsLoginProto.SshPublicKey response =
50+
* osLoginServiceClient.createSshPublicKey(parent, sshPublicKey);
4951
* }
5052
* }</pre>
5153
*
@@ -169,6 +171,133 @@ public OsLoginServiceStub getStub() {
169171
return stub;
170172
}
171173

174+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
175+
/**
176+
* Create an SSH public key
177+
*
178+
* <p>Sample code:
179+
*
180+
* <pre>{@code
181+
* // This snippet has been automatically generated and should be regarded as a code template only.
182+
* // It will require modifications to work:
183+
* // - It may require correct/in-range values for request initialization.
184+
* // - It may require specifying regional endpoints when creating the service client as shown in
185+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
186+
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
187+
* UserName parent = UserName.of("[USER]");
188+
* OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build();
189+
* OsLoginProto.SshPublicKey response =
190+
* osLoginServiceClient.createSshPublicKey(parent, sshPublicKey);
191+
* }
192+
* }</pre>
193+
*
194+
* @param parent Required. The unique ID for the user in format `users/{user}`.
195+
* @param sshPublicKey Required. The SSH public key and expiration time.
196+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
197+
*/
198+
public final OsLoginProto.SshPublicKey createSshPublicKey(
199+
UserName parent, OsLoginProto.SshPublicKey sshPublicKey) {
200+
CreateSshPublicKeyRequest request =
201+
CreateSshPublicKeyRequest.newBuilder()
202+
.setParent(parent == null ? null : parent.toString())
203+
.setSshPublicKey(sshPublicKey)
204+
.build();
205+
return createSshPublicKey(request);
206+
}
207+
208+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
209+
/**
210+
* Create an SSH public key
211+
*
212+
* <p>Sample code:
213+
*
214+
* <pre>{@code
215+
* // This snippet has been automatically generated and should be regarded as a code template only.
216+
* // It will require modifications to work:
217+
* // - It may require correct/in-range values for request initialization.
218+
* // - It may require specifying regional endpoints when creating the service client as shown in
219+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
220+
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
221+
* String parent = UserName.of("[USER]").toString();
222+
* OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build();
223+
* OsLoginProto.SshPublicKey response =
224+
* osLoginServiceClient.createSshPublicKey(parent, sshPublicKey);
225+
* }
226+
* }</pre>
227+
*
228+
* @param parent Required. The unique ID for the user in format `users/{user}`.
229+
* @param sshPublicKey Required. The SSH public key and expiration time.
230+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
231+
*/
232+
public final OsLoginProto.SshPublicKey createSshPublicKey(
233+
String parent, OsLoginProto.SshPublicKey sshPublicKey) {
234+
CreateSshPublicKeyRequest request =
235+
CreateSshPublicKeyRequest.newBuilder()
236+
.setParent(parent)
237+
.setSshPublicKey(sshPublicKey)
238+
.build();
239+
return createSshPublicKey(request);
240+
}
241+
242+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
243+
/**
244+
* Create an SSH public key
245+
*
246+
* <p>Sample code:
247+
*
248+
* <pre>{@code
249+
* // This snippet has been automatically generated and should be regarded as a code template only.
250+
* // It will require modifications to work:
251+
* // - It may require correct/in-range values for request initialization.
252+
* // - It may require specifying regional endpoints when creating the service client as shown in
253+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
254+
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
255+
* CreateSshPublicKeyRequest request =
256+
* CreateSshPublicKeyRequest.newBuilder()
257+
* .setParent(UserName.of("[USER]").toString())
258+
* .setSshPublicKey(OsLoginProto.SshPublicKey.newBuilder().build())
259+
* .build();
260+
* OsLoginProto.SshPublicKey response = osLoginServiceClient.createSshPublicKey(request);
261+
* }
262+
* }</pre>
263+
*
264+
* @param request The request object containing all of the parameters for the API call.
265+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
266+
*/
267+
public final OsLoginProto.SshPublicKey createSshPublicKey(CreateSshPublicKeyRequest request) {
268+
return createSshPublicKeyCallable().call(request);
269+
}
270+
271+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
272+
/**
273+
* Create an SSH public key
274+
*
275+
* <p>Sample code:
276+
*
277+
* <pre>{@code
278+
* // This snippet has been automatically generated and should be regarded as a code template only.
279+
* // It will require modifications to work:
280+
* // - It may require correct/in-range values for request initialization.
281+
* // - It may require specifying regional endpoints when creating the service client as shown in
282+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
283+
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
284+
* CreateSshPublicKeyRequest request =
285+
* CreateSshPublicKeyRequest.newBuilder()
286+
* .setParent(UserName.of("[USER]").toString())
287+
* .setSshPublicKey(OsLoginProto.SshPublicKey.newBuilder().build())
288+
* .build();
289+
* ApiFuture<OsLoginProto.SshPublicKey> future =
290+
* osLoginServiceClient.createSshPublicKeyCallable().futureCall(request);
291+
* // Do something.
292+
* OsLoginProto.SshPublicKey response = future.get();
293+
* }
294+
* }</pre>
295+
*/
296+
public final UnaryCallable<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
297+
createSshPublicKeyCallable() {
298+
return stub.createSshPublicKeyCallable();
299+
}
300+
172301
// AUTO-GENERATED DOCUMENTATION AND METHOD.
173302
/**
174303
* Deletes a POSIX account.

java-os-login/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceSettings.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
5050
* build() is called, the tree of builders is called to create the complete settings object.
5151
*
52-
* <p>For example, to set the total timeout of deletePosixAccount to 30 seconds:
52+
* <p>For example, to set the total timeout of createSshPublicKey to 30 seconds:
5353
*
5454
* <pre>{@code
5555
* // This snippet has been automatically generated and should be regarded as a code template only.
@@ -60,10 +60,10 @@
6060
* OsLoginServiceSettings.Builder osLoginServiceSettingsBuilder =
6161
* OsLoginServiceSettings.newBuilder();
6262
* osLoginServiceSettingsBuilder
63-
* .deletePosixAccountSettings()
63+
* .createSshPublicKeySettings()
6464
* .setRetrySettings(
6565
* osLoginServiceSettingsBuilder
66-
* .deletePosixAccountSettings()
66+
* .createSshPublicKeySettings()
6767
* .getRetrySettings()
6868
* .toBuilder()
6969
* .setTotalTimeout(Duration.ofSeconds(30))
@@ -74,6 +74,12 @@
7474
@Generated("by gapic-generator-java")
7575
public class OsLoginServiceSettings extends ClientSettings<OsLoginServiceSettings> {
7676

77+
/** Returns the object with the settings used for calls to createSshPublicKey. */
78+
public UnaryCallSettings<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
79+
createSshPublicKeySettings() {
80+
return ((OsLoginServiceStubSettings) getStubSettings()).createSshPublicKeySettings();
81+
}
82+
7783
/** Returns the object with the settings used for calls to deletePosixAccount. */
7884
public UnaryCallSettings<DeletePosixAccountRequest, Empty> deletePosixAccountSettings() {
7985
return ((OsLoginServiceStubSettings) getStubSettings()).deletePosixAccountSettings();
@@ -222,6 +228,12 @@ public Builder applyToAllUnaryMethods(
222228
return this;
223229
}
224230

231+
/** Returns the builder for the settings used for calls to createSshPublicKey. */
232+
public UnaryCallSettings.Builder<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
233+
createSshPublicKeySettings() {
234+
return getStubSettingsBuilder().createSshPublicKeySettings();
235+
}
236+
225237
/** Returns the builder for the settings used for calls to deletePosixAccount. */
226238
public UnaryCallSettings.Builder<DeletePosixAccountRequest, Empty>
227239
deletePosixAccountSettings() {

java-os-login/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/gapic_metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"grpc": {
1111
"libraryClient": "OsLoginServiceClient",
1212
"rpcs": {
13+
"CreateSshPublicKey": {
14+
"methods": ["createSshPublicKey", "createSshPublicKey", "createSshPublicKey", "createSshPublicKeyCallable"]
15+
},
1316
"DeletePosixAccount": {
1417
"methods": ["deletePosixAccount", "deletePosixAccount", "deletePosixAccount", "deletePosixAccountCallable"]
1518
},

java-os-login/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/package-info.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
* // - It may require specifying regional endpoints when creating the service client as shown in
3434
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
3535
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
36-
* PosixAccountName name = PosixAccountName.of("[USER]", "[PROJECT]");
37-
* osLoginServiceClient.deletePosixAccount(name);
36+
* UserName parent = UserName.of("[USER]");
37+
* OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build();
38+
* OsLoginProto.SshPublicKey response =
39+
* osLoginServiceClient.createSshPublicKey(parent, sshPublicKey);
3840
* }
3941
* }</pre>
4042
*/

java-os-login/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/GrpcOsLoginServiceStub.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.api.gax.rpc.ClientContext;
2424
import com.google.api.gax.rpc.UnaryCallable;
2525
import com.google.cloud.oslogin.common.OsLoginProto;
26+
import com.google.cloud.oslogin.v1.CreateSshPublicKeyRequest;
2627
import com.google.cloud.oslogin.v1.DeletePosixAccountRequest;
2728
import com.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest;
2829
import com.google.cloud.oslogin.v1.GetLoginProfileRequest;
@@ -48,6 +49,17 @@
4849
*/
4950
@Generated("by gapic-generator-java")
5051
public class GrpcOsLoginServiceStub extends OsLoginServiceStub {
52+
private static final MethodDescriptor<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
53+
createSshPublicKeyMethodDescriptor =
54+
MethodDescriptor.<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>newBuilder()
55+
.setType(MethodDescriptor.MethodType.UNARY)
56+
.setFullMethodName("google.cloud.oslogin.v1.OsLoginService/CreateSshPublicKey")
57+
.setRequestMarshaller(
58+
ProtoUtils.marshaller(CreateSshPublicKeyRequest.getDefaultInstance()))
59+
.setResponseMarshaller(
60+
ProtoUtils.marshaller(OsLoginProto.SshPublicKey.getDefaultInstance()))
61+
.build();
62+
5163
private static final MethodDescriptor<DeletePosixAccountRequest, Empty>
5264
deletePosixAccountMethodDescriptor =
5365
MethodDescriptor.<DeletePosixAccountRequest, Empty>newBuilder()
@@ -111,6 +123,8 @@ public class GrpcOsLoginServiceStub extends OsLoginServiceStub {
111123
ProtoUtils.marshaller(OsLoginProto.SshPublicKey.getDefaultInstance()))
112124
.build();
113125

126+
private final UnaryCallable<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
127+
createSshPublicKeyCallable;
114128
private final UnaryCallable<DeletePosixAccountRequest, Empty> deletePosixAccountCallable;
115129
private final UnaryCallable<DeleteSshPublicKeyRequest, Empty> deleteSshPublicKeyCallable;
116130
private final UnaryCallable<GetLoginProfileRequest, LoginProfile> getLoginProfileCallable;
@@ -165,6 +179,17 @@ protected GrpcOsLoginServiceStub(
165179
this.callableFactory = callableFactory;
166180
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
167181

182+
GrpcCallSettings<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
183+
createSshPublicKeyTransportSettings =
184+
GrpcCallSettings.<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>newBuilder()
185+
.setMethodDescriptor(createSshPublicKeyMethodDescriptor)
186+
.setParamsExtractor(
187+
request -> {
188+
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
189+
params.put("parent", String.valueOf(request.getParent()));
190+
return params.build();
191+
})
192+
.build();
168193
GrpcCallSettings<DeletePosixAccountRequest, Empty> deletePosixAccountTransportSettings =
169194
GrpcCallSettings.<DeletePosixAccountRequest, Empty>newBuilder()
170195
.setMethodDescriptor(deletePosixAccountMethodDescriptor)
@@ -229,6 +254,11 @@ protected GrpcOsLoginServiceStub(
229254
})
230255
.build();
231256

257+
this.createSshPublicKeyCallable =
258+
callableFactory.createUnaryCallable(
259+
createSshPublicKeyTransportSettings,
260+
settings.createSshPublicKeySettings(),
261+
clientContext);
232262
this.deletePosixAccountCallable =
233263
callableFactory.createUnaryCallable(
234264
deletePosixAccountTransportSettings,
@@ -264,6 +294,12 @@ public GrpcOperationsStub getOperationsStub() {
264294
return operationsStub;
265295
}
266296

297+
@Override
298+
public UnaryCallable<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
299+
createSshPublicKeyCallable() {
300+
return createSshPublicKeyCallable;
301+
}
302+
267303
@Override
268304
public UnaryCallable<DeletePosixAccountRequest, Empty> deletePosixAccountCallable() {
269305
return deletePosixAccountCallable;

0 commit comments

Comments
 (0)