Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions java-os-login/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-os-login</artifactId>
<version>2.4.0</version>
<version>2.5.0</version>
</dependency>
```

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

```Groovy
implementation 'com.google.cloud:google-cloud-os-login:2.4.0'
implementation 'com.google.cloud:google-cloud-os-login:2.5.0'
```

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

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

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

[product-docs]: https://cloud.google.com/compute/docs/oslogin/
[javadocs]: https://cloud.google.com/java/docs/reference/google-cloud-os-login/latest/overview
[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java7.svg
[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java7.html
[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8.svg
[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8.html
[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8-osx.svg
[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8-osx.html
[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8-win.svg
[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java8-win.html
[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java11.svg
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-os-login/java11.html
[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java7.svg
[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java7.html
[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8.svg
[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8.html
[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8-osx.svg
[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8-osx.html
[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8-win.svg
[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java8-win.html
[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.svg
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-os-login.svg
[maven-version-link]: https://search.maven.org/search?q=g:com.google.cloud%20AND%20a:google-cloud-os-login&core=gav
Expand All @@ -180,9 +180,9 @@ Java is a registered trademark of Oracle and/or its affiliates.
[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects
[cloud-sdk]: https://cloud.google.com/sdk/
[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/main/troubleshooting/readme.md#troubleshooting
[contributing]: https://github.com/googleapis/java-os-login/blob/main/CONTRIBUTING.md
[code-of-conduct]: https://github.com/googleapis/java-os-login/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct
[license]: https://github.com/googleapis/java-os-login/blob/main/LICENSE
[contributing]: https://github.com/googleapis/google-cloud-java/blob/main/CONTRIBUTING.md
[code-of-conduct]: https://github.com/googleapis/google-cloud-java/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct
[license]: https://github.com/googleapis/google-cloud-java/blob/main/LICENSE
[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing
[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=oslogin.googleapis.com
[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
* ProjectName name = ProjectName.of("[USER]", "[PROJECT]");
* osLoginServiceClient.deletePosixAccount(name);
* UserName parent = UserName.of("[USER]");
* OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build();
* OsLoginProto.SshPublicKey response =
* osLoginServiceClient.createSshPublicKey(parent, sshPublicKey);
* }
* }</pre>
*
Expand Down Expand Up @@ -169,6 +171,133 @@ public OsLoginServiceStub getStub() {
return stub;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Create an SSH public key
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
* UserName parent = UserName.of("[USER]");
* OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build();
* OsLoginProto.SshPublicKey response =
* osLoginServiceClient.createSshPublicKey(parent, sshPublicKey);
* }
* }</pre>
*
* @param parent Required. The unique ID for the user in format `users/{user}`.
* @param sshPublicKey Required. The SSH public key and expiration time.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OsLoginProto.SshPublicKey createSshPublicKey(
UserName parent, OsLoginProto.SshPublicKey sshPublicKey) {
CreateSshPublicKeyRequest request =
CreateSshPublicKeyRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setSshPublicKey(sshPublicKey)
.build();
return createSshPublicKey(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Create an SSH public key
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
* String parent = UserName.of("[USER]").toString();
* OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build();
* OsLoginProto.SshPublicKey response =
* osLoginServiceClient.createSshPublicKey(parent, sshPublicKey);
* }
* }</pre>
*
* @param parent Required. The unique ID for the user in format `users/{user}`.
* @param sshPublicKey Required. The SSH public key and expiration time.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OsLoginProto.SshPublicKey createSshPublicKey(
String parent, OsLoginProto.SshPublicKey sshPublicKey) {
CreateSshPublicKeyRequest request =
CreateSshPublicKeyRequest.newBuilder()
.setParent(parent)
.setSshPublicKey(sshPublicKey)
.build();
return createSshPublicKey(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Create an SSH public key
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
* CreateSshPublicKeyRequest request =
* CreateSshPublicKeyRequest.newBuilder()
* .setParent(UserName.of("[USER]").toString())
* .setSshPublicKey(OsLoginProto.SshPublicKey.newBuilder().build())
* .build();
* OsLoginProto.SshPublicKey response = osLoginServiceClient.createSshPublicKey(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OsLoginProto.SshPublicKey createSshPublicKey(CreateSshPublicKeyRequest request) {
return createSshPublicKeyCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Create an SSH public key
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
* CreateSshPublicKeyRequest request =
* CreateSshPublicKeyRequest.newBuilder()
* .setParent(UserName.of("[USER]").toString())
* .setSshPublicKey(OsLoginProto.SshPublicKey.newBuilder().build())
* .build();
* ApiFuture<OsLoginProto.SshPublicKey> future =
* osLoginServiceClient.createSshPublicKeyCallable().futureCall(request);
* // Do something.
* OsLoginProto.SshPublicKey response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
createSshPublicKeyCallable() {
return stub.createSshPublicKeyCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a POSIX account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of deletePosixAccount to 30 seconds:
* <p>For example, to set the total timeout of createSshPublicKey to 30 seconds:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
Expand All @@ -60,10 +60,10 @@
* OsLoginServiceSettings.Builder osLoginServiceSettingsBuilder =
* OsLoginServiceSettings.newBuilder();
* osLoginServiceSettingsBuilder
* .deletePosixAccountSettings()
* .createSshPublicKeySettings()
* .setRetrySettings(
* osLoginServiceSettingsBuilder
* .deletePosixAccountSettings()
* .createSshPublicKeySettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
Expand All @@ -74,6 +74,12 @@
@Generated("by gapic-generator-java")
public class OsLoginServiceSettings extends ClientSettings<OsLoginServiceSettings> {

/** Returns the object with the settings used for calls to createSshPublicKey. */
public UnaryCallSettings<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
createSshPublicKeySettings() {
return ((OsLoginServiceStubSettings) getStubSettings()).createSshPublicKeySettings();
}

/** Returns the object with the settings used for calls to deletePosixAccount. */
public UnaryCallSettings<DeletePosixAccountRequest, Empty> deletePosixAccountSettings() {
return ((OsLoginServiceStubSettings) getStubSettings()).deletePosixAccountSettings();
Expand Down Expand Up @@ -222,6 +228,12 @@ public Builder applyToAllUnaryMethods(
return this;
}

/** Returns the builder for the settings used for calls to createSshPublicKey. */
public UnaryCallSettings.Builder<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
createSshPublicKeySettings() {
return getStubSettingsBuilder().createSshPublicKeySettings();
}

/** Returns the builder for the settings used for calls to deletePosixAccount. */
public UnaryCallSettings.Builder<DeletePosixAccountRequest, Empty>
deletePosixAccountSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"grpc": {
"libraryClient": "OsLoginServiceClient",
"rpcs": {
"CreateSshPublicKey": {
"methods": ["createSshPublicKey", "createSshPublicKey", "createSshPublicKey", "createSshPublicKeyCallable"]
},
"DeletePosixAccount": {
"methods": ["deletePosixAccount", "deletePosixAccount", "deletePosixAccount", "deletePosixAccountCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create()) {
* PosixAccountName name = PosixAccountName.of("[USER]", "[PROJECT]");
* osLoginServiceClient.deletePosixAccount(name);
* UserName parent = UserName.of("[USER]");
* OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build();
* OsLoginProto.SshPublicKey response =
* osLoginServiceClient.createSshPublicKey(parent, sshPublicKey);
* }
* }</pre>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.oslogin.common.OsLoginProto;
import com.google.cloud.oslogin.v1.CreateSshPublicKeyRequest;
import com.google.cloud.oslogin.v1.DeletePosixAccountRequest;
import com.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest;
import com.google.cloud.oslogin.v1.GetLoginProfileRequest;
Expand All @@ -48,6 +49,17 @@
*/
@Generated("by gapic-generator-java")
public class GrpcOsLoginServiceStub extends OsLoginServiceStub {
private static final MethodDescriptor<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
createSshPublicKeyMethodDescriptor =
MethodDescriptor.<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.oslogin.v1.OsLoginService/CreateSshPublicKey")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateSshPublicKeyRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(OsLoginProto.SshPublicKey.getDefaultInstance()))
.build();

private static final MethodDescriptor<DeletePosixAccountRequest, Empty>
deletePosixAccountMethodDescriptor =
MethodDescriptor.<DeletePosixAccountRequest, Empty>newBuilder()
Expand Down Expand Up @@ -111,6 +123,8 @@ public class GrpcOsLoginServiceStub extends OsLoginServiceStub {
ProtoUtils.marshaller(OsLoginProto.SshPublicKey.getDefaultInstance()))
.build();

private final UnaryCallable<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
createSshPublicKeyCallable;
private final UnaryCallable<DeletePosixAccountRequest, Empty> deletePosixAccountCallable;
private final UnaryCallable<DeleteSshPublicKeyRequest, Empty> deleteSshPublicKeyCallable;
private final UnaryCallable<GetLoginProfileRequest, LoginProfile> getLoginProfileCallable;
Expand Down Expand Up @@ -165,6 +179,17 @@ protected GrpcOsLoginServiceStub(
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);

GrpcCallSettings<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
createSshPublicKeyTransportSettings =
GrpcCallSettings.<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>newBuilder()
.setMethodDescriptor(createSshPublicKeyMethodDescriptor)
.setParamsExtractor(
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("parent", String.valueOf(request.getParent()));
return params.build();
})
.build();
GrpcCallSettings<DeletePosixAccountRequest, Empty> deletePosixAccountTransportSettings =
GrpcCallSettings.<DeletePosixAccountRequest, Empty>newBuilder()
.setMethodDescriptor(deletePosixAccountMethodDescriptor)
Expand Down Expand Up @@ -229,6 +254,11 @@ protected GrpcOsLoginServiceStub(
})
.build();

this.createSshPublicKeyCallable =
callableFactory.createUnaryCallable(
createSshPublicKeyTransportSettings,
settings.createSshPublicKeySettings(),
clientContext);
this.deletePosixAccountCallable =
callableFactory.createUnaryCallable(
deletePosixAccountTransportSettings,
Expand Down Expand Up @@ -264,6 +294,12 @@ public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}

@Override
public UnaryCallable<CreateSshPublicKeyRequest, OsLoginProto.SshPublicKey>
createSshPublicKeyCallable() {
return createSshPublicKeyCallable;
}

@Override
public UnaryCallable<DeletePosixAccountRequest, Empty> deletePosixAccountCallable() {
return deletePosixAccountCallable;
Expand Down
Loading