Class OsLoginServiceClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
The Cloud OS Login API allows you to manage users and their associated SSH public keys for logging into virtual machines on Google Cloud Platform.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// 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);
}
Note: close() needs to be called on the OsLoginServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
CreateSshPublicKey |
Create an SSH public key |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeletePosixAccount |
Deletes a POSIX account. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteSshPublicKey |
Deletes an SSH public key. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLoginProfile |
Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetSshPublicKey |
Retrieves an SSH public key. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ImportSshPublicKey |
Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateSshPublicKey |
Updates an SSH public key and returns the profile information. This method supports patch semantics. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of OsLoginServiceSettings to create(). For example:
To customize credentials:
// 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
OsLoginServiceSettings osLoginServiceSettings =
OsLoginServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create(osLoginServiceSettings);
To customize the endpoint:
// 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
OsLoginServiceSettings osLoginServiceSettings =
OsLoginServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create(osLoginServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// 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
OsLoginServiceSettings osLoginServiceSettings =
OsLoginServiceSettings.newHttpJsonBuilder().build();
OsLoginServiceClient osLoginServiceClient = OsLoginServiceClient.create(osLoginServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOsLoginServiceClient(OsLoginServiceSettings settings) Constructs an instance of OsLoginServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) final voidclose()static final OsLoginServiceClientcreate()Constructs an instance of OsLoginServiceClient with default settings.static final OsLoginServiceClientcreate(OsLoginServiceSettings settings) Constructs an instance of OsLoginServiceClient, using the given settings.static final OsLoginServiceClientcreate(OsLoginServiceStub stub) Constructs an instance of OsLoginServiceClient, using the given stub for making calls.Create an SSH public keycreateSshPublicKey(UserName parent, OsLoginProto.SshPublicKey sshPublicKey) Create an SSH public keycreateSshPublicKey(String parent, OsLoginProto.SshPublicKey sshPublicKey) Create an SSH public keyCreate an SSH public keyfinal voidDeletes a POSIX account.final voidDeletes a POSIX account.final voiddeletePosixAccount(String name) Deletes a POSIX account.final UnaryCallable<DeletePosixAccountRequest,com.google.protobuf.Empty> Deletes a POSIX account.final voidDeletes an SSH public key.final voidDeletes an SSH public key.final voiddeleteSshPublicKey(String name) Deletes an SSH public key.final UnaryCallable<DeleteSshPublicKeyRequest,com.google.protobuf.Empty> Deletes an SSH public key.final LoginProfilegetLoginProfile(GetLoginProfileRequest request) Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.final LoginProfilegetLoginProfile(UserName name) Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.final LoginProfilegetLoginProfile(String name) Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.final OsLoginServiceSettingsRetrieves an SSH public key.getSshPublicKey(GetSshPublicKeyRequest request) Retrieves an SSH public key.getSshPublicKey(String name) Retrieves an SSH public key.Retrieves an SSH public key.getStub()Adds an SSH public key and returns the profile information.importSshPublicKey(UserName parent, OsLoginProto.SshPublicKey sshPublicKey) Adds an SSH public key and returns the profile information.importSshPublicKey(UserName parent, OsLoginProto.SshPublicKey sshPublicKey, String projectId) Adds an SSH public key and returns the profile information.importSshPublicKey(String parent, OsLoginProto.SshPublicKey sshPublicKey) Adds an SSH public key and returns the profile information.importSshPublicKey(String parent, OsLoginProto.SshPublicKey sshPublicKey, String projectId) Adds an SSH public key and returns the profile information.Adds an SSH public key and returns the profile information.booleanbooleanvoidshutdown()voidupdateSshPublicKey(FingerprintName name, OsLoginProto.SshPublicKey sshPublicKey) Updates an SSH public key and returns the profile information.updateSshPublicKey(FingerprintName name, OsLoginProto.SshPublicKey sshPublicKey, com.google.protobuf.FieldMask updateMask) Updates an SSH public key and returns the profile information.Updates an SSH public key and returns the profile information.updateSshPublicKey(String name, OsLoginProto.SshPublicKey sshPublicKey) Updates an SSH public key and returns the profile information.updateSshPublicKey(String name, OsLoginProto.SshPublicKey sshPublicKey, com.google.protobuf.FieldMask updateMask) Updates an SSH public key and returns the profile information.Updates an SSH public key and returns the profile information.
-
Constructor Details
-
OsLoginServiceClient
Constructs an instance of OsLoginServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.- Throws:
IOException
-
OsLoginServiceClient
-
-
Method Details
-
create
Constructs an instance of OsLoginServiceClient with default settings.- Throws:
IOException
-
create
Constructs an instance of OsLoginServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
Constructs an instance of OsLoginServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(OsLoginServiceSettings). -
getSettings
-
getStub
-
createSshPublicKey
public final OsLoginProto.SshPublicKey createSshPublicKey(UserName parent, OsLoginProto.SshPublicKey sshPublicKey) Create an SSH public keySample 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); }- Parameters:
parent- Required. The unique ID for the user in format `users/{user}`.sshPublicKey- Required. The SSH public key and expiration time.- Throws:
ApiException- if the remote call fails
-
createSshPublicKey
public final OsLoginProto.SshPublicKey createSshPublicKey(String parent, OsLoginProto.SshPublicKey sshPublicKey) Create an SSH public keySample 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); }- Parameters:
parent- Required. The unique ID for the user in format `users/{user}`.sshPublicKey- Required. The SSH public key and expiration time.- Throws:
ApiException- if the remote call fails
-
createSshPublicKey
Create an SSH public keySample 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); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createSshPublicKeyCallable
public final UnaryCallable<CreateSshPublicKeyRequest,OsLoginProto.SshPublicKey> createSshPublicKeyCallable()Create an SSH public keySample 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(); } -
deletePosixAccount
Deletes a POSIX account.Sample 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()) { ProjectName name = ProjectName.of("[USER]", "[PROJECT]"); osLoginServiceClient.deletePosixAccount(name); }- Parameters:
name- Required. A reference to the POSIX account to update. POSIX accounts are identified by the project ID they are associated with. A reference to the POSIX account is in format `users/{user}/projects/{project}`.- Throws:
ApiException- if the remote call fails
-
deletePosixAccount
Deletes a POSIX account.Sample 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 name = ProjectName.of("[USER]", "[PROJECT]").toString(); osLoginServiceClient.deletePosixAccount(name); }- Parameters:
name- Required. A reference to the POSIX account to update. POSIX accounts are identified by the project ID they are associated with. A reference to the POSIX account is in format `users/{user}/projects/{project}`.- Throws:
ApiException- if the remote call fails
-
deletePosixAccount
Deletes a POSIX account.Sample 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()) { DeletePosixAccountRequest request = DeletePosixAccountRequest.newBuilder() .setName(ProjectName.of("[USER]", "[PROJECT]").toString()) .build(); osLoginServiceClient.deletePosixAccount(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deletePosixAccountCallable
public final UnaryCallable<DeletePosixAccountRequest,com.google.protobuf.Empty> deletePosixAccountCallable()Deletes a POSIX account.Sample 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()) { DeletePosixAccountRequest request = DeletePosixAccountRequest.newBuilder() .setName(ProjectName.of("[USER]", "[PROJECT]").toString()) .build(); ApiFuture<Empty> future = osLoginServiceClient.deletePosixAccountCallable().futureCall(request); // Do something. future.get(); } -
deleteSshPublicKey
Deletes an SSH public key.Sample 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()) { FingerprintName name = FingerprintName.of("[USER]", "[FINGERPRINT]"); osLoginServiceClient.deleteSshPublicKey(name); }- Parameters:
name- Required. The fingerprint of the public key to update. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format `users/{user}/sshPublicKeys/{fingerprint}`.- Throws:
ApiException- if the remote call fails
-
deleteSshPublicKey
Deletes an SSH public key.Sample 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 name = FingerprintName.of("[USER]", "[FINGERPRINT]").toString(); osLoginServiceClient.deleteSshPublicKey(name); }- Parameters:
name- Required. The fingerprint of the public key to update. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format `users/{user}/sshPublicKeys/{fingerprint}`.- Throws:
ApiException- if the remote call fails
-
deleteSshPublicKey
Deletes an SSH public key.Sample 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()) { DeleteSshPublicKeyRequest request = DeleteSshPublicKeyRequest.newBuilder() .setName(FingerprintName.of("[USER]", "[FINGERPRINT]").toString()) .build(); osLoginServiceClient.deleteSshPublicKey(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteSshPublicKeyCallable
public final UnaryCallable<DeleteSshPublicKeyRequest,com.google.protobuf.Empty> deleteSshPublicKeyCallable()Deletes an SSH public key.Sample 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()) { DeleteSshPublicKeyRequest request = DeleteSshPublicKeyRequest.newBuilder() .setName(FingerprintName.of("[USER]", "[FINGERPRINT]").toString()) .build(); ApiFuture<Empty> future = osLoginServiceClient.deleteSshPublicKeyCallable().futureCall(request); // Do something. future.get(); } -
getLoginProfile
Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.Sample 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 name = UserName.of("[USER]"); LoginProfile response = osLoginServiceClient.getLoginProfile(name); }- Parameters:
name- Required. The unique ID for the user in format `users/{user}`.- Throws:
ApiException- if the remote call fails
-
getLoginProfile
Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.Sample 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 name = UserName.of("[USER]").toString(); LoginProfile response = osLoginServiceClient.getLoginProfile(name); }- Parameters:
name- Required. The unique ID for the user in format `users/{user}`.- Throws:
ApiException- if the remote call fails
-
getLoginProfile
Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.Sample 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()) { GetLoginProfileRequest request = GetLoginProfileRequest.newBuilder() .setName(UserName.of("[USER]").toString()) .setProjectId("projectId-894832108") .setSystemId("systemId1976085418") .build(); LoginProfile response = osLoginServiceClient.getLoginProfile(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getLoginProfileCallable
Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.Sample 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()) { GetLoginProfileRequest request = GetLoginProfileRequest.newBuilder() .setName(UserName.of("[USER]").toString()) .setProjectId("projectId-894832108") .setSystemId("systemId1976085418") .build(); ApiFuture<LoginProfile> future = osLoginServiceClient.getLoginProfileCallable().futureCall(request); // Do something. LoginProfile response = future.get(); } -
getSshPublicKey
Retrieves an SSH public key.Sample 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()) { FingerprintName name = FingerprintName.of("[USER]", "[FINGERPRINT]"); OsLoginProto.SshPublicKey response = osLoginServiceClient.getSshPublicKey(name); }- Parameters:
name- Required. The fingerprint of the public key to retrieve. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format `users/{user}/sshPublicKeys/{fingerprint}`.- Throws:
ApiException- if the remote call fails
-
getSshPublicKey
Retrieves an SSH public key.Sample 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 name = FingerprintName.of("[USER]", "[FINGERPRINT]").toString(); OsLoginProto.SshPublicKey response = osLoginServiceClient.getSshPublicKey(name); }- Parameters:
name- Required. The fingerprint of the public key to retrieve. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format `users/{user}/sshPublicKeys/{fingerprint}`.- Throws:
ApiException- if the remote call fails
-
getSshPublicKey
Retrieves an SSH public key.Sample 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()) { GetSshPublicKeyRequest request = GetSshPublicKeyRequest.newBuilder() .setName(FingerprintName.of("[USER]", "[FINGERPRINT]").toString()) .build(); OsLoginProto.SshPublicKey response = osLoginServiceClient.getSshPublicKey(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getSshPublicKeyCallable
public final UnaryCallable<GetSshPublicKeyRequest,OsLoginProto.SshPublicKey> getSshPublicKeyCallable()Retrieves an SSH public key.Sample 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()) { GetSshPublicKeyRequest request = GetSshPublicKeyRequest.newBuilder() .setName(FingerprintName.of("[USER]", "[FINGERPRINT]").toString()) .build(); ApiFuture<OsLoginProto.SshPublicKey> future = osLoginServiceClient.getSshPublicKeyCallable().futureCall(request); // Do something. OsLoginProto.SshPublicKey response = future.get(); } -
importSshPublicKey
public final ImportSshPublicKeyResponse importSshPublicKey(UserName parent, OsLoginProto.SshPublicKey sshPublicKey) Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.Sample 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(); ImportSshPublicKeyResponse response = osLoginServiceClient.importSshPublicKey(parent, sshPublicKey); }- Parameters:
parent- Required. The unique ID for the user in format `users/{user}`.sshPublicKey- Optional. The SSH public key and expiration time.- Throws:
ApiException- if the remote call fails
-
importSshPublicKey
public final ImportSshPublicKeyResponse importSshPublicKey(String parent, OsLoginProto.SshPublicKey sshPublicKey) Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.Sample 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(); ImportSshPublicKeyResponse response = osLoginServiceClient.importSshPublicKey(parent, sshPublicKey); }- Parameters:
parent- Required. The unique ID for the user in format `users/{user}`.sshPublicKey- Optional. The SSH public key and expiration time.- Throws:
ApiException- if the remote call fails
-
importSshPublicKey
public final ImportSshPublicKeyResponse importSshPublicKey(UserName parent, OsLoginProto.SshPublicKey sshPublicKey, String projectId) Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.Sample 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(); String projectId = "projectId-894832108"; ImportSshPublicKeyResponse response = osLoginServiceClient.importSshPublicKey(parent, sshPublicKey, projectId); }- Parameters:
parent- Required. The unique ID for the user in format `users/{user}`.sshPublicKey- Optional. The SSH public key and expiration time.projectId- The project ID of the Google Cloud Platform project.- Throws:
ApiException- if the remote call fails
-
importSshPublicKey
public final ImportSshPublicKeyResponse importSshPublicKey(String parent, OsLoginProto.SshPublicKey sshPublicKey, String projectId) Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.Sample 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(); String projectId = "projectId-894832108"; ImportSshPublicKeyResponse response = osLoginServiceClient.importSshPublicKey(parent, sshPublicKey, projectId); }- Parameters:
parent- Required. The unique ID for the user in format `users/{user}`.sshPublicKey- Optional. The SSH public key and expiration time.projectId- The project ID of the Google Cloud Platform project.- Throws:
ApiException- if the remote call fails
-
importSshPublicKey
Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.Sample 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()) { ImportSshPublicKeyRequest request = ImportSshPublicKeyRequest.newBuilder() .setParent(UserName.of("[USER]").toString()) .setSshPublicKey(OsLoginProto.SshPublicKey.newBuilder().build()) .setProjectId("projectId-894832108") .addAllRegions(new ArrayList<String>()) .build(); ImportSshPublicKeyResponse response = osLoginServiceClient.importSshPublicKey(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
importSshPublicKeyCallable
public final UnaryCallable<ImportSshPublicKeyRequest,ImportSshPublicKeyResponse> importSshPublicKeyCallable()Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.Sample 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()) { ImportSshPublicKeyRequest request = ImportSshPublicKeyRequest.newBuilder() .setParent(UserName.of("[USER]").toString()) .setSshPublicKey(OsLoginProto.SshPublicKey.newBuilder().build()) .setProjectId("projectId-894832108") .addAllRegions(new ArrayList<String>()) .build(); ApiFuture<ImportSshPublicKeyResponse> future = osLoginServiceClient.importSshPublicKeyCallable().futureCall(request); // Do something. ImportSshPublicKeyResponse response = future.get(); } -
updateSshPublicKey
public final OsLoginProto.SshPublicKey updateSshPublicKey(FingerprintName name, OsLoginProto.SshPublicKey sshPublicKey) Updates an SSH public key and returns the profile information. This method supports patch semantics.Sample 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()) { FingerprintName name = FingerprintName.of("[USER]", "[FINGERPRINT]"); OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build(); OsLoginProto.SshPublicKey response = osLoginServiceClient.updateSshPublicKey(name, sshPublicKey); }- Parameters:
name- Required. The fingerprint of the public key to update. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format `users/{user}/sshPublicKeys/{fingerprint}`.sshPublicKey- Required. The SSH public key and expiration time.- Throws:
ApiException- if the remote call fails
-
updateSshPublicKey
public final OsLoginProto.SshPublicKey updateSshPublicKey(String name, OsLoginProto.SshPublicKey sshPublicKey) Updates an SSH public key and returns the profile information. This method supports patch semantics.Sample 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 name = FingerprintName.of("[USER]", "[FINGERPRINT]").toString(); OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build(); OsLoginProto.SshPublicKey response = osLoginServiceClient.updateSshPublicKey(name, sshPublicKey); }- Parameters:
name- Required. The fingerprint of the public key to update. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format `users/{user}/sshPublicKeys/{fingerprint}`.sshPublicKey- Required. The SSH public key and expiration time.- Throws:
ApiException- if the remote call fails
-
updateSshPublicKey
public final OsLoginProto.SshPublicKey updateSshPublicKey(FingerprintName name, OsLoginProto.SshPublicKey sshPublicKey, com.google.protobuf.FieldMask updateMask) Updates an SSH public key and returns the profile information. This method supports patch semantics.Sample 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()) { FingerprintName name = FingerprintName.of("[USER]", "[FINGERPRINT]"); OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); OsLoginProto.SshPublicKey response = osLoginServiceClient.updateSshPublicKey(name, sshPublicKey, updateMask); }- Parameters:
name- Required. The fingerprint of the public key to update. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format `users/{user}/sshPublicKeys/{fingerprint}`.sshPublicKey- Required. The SSH public key and expiration time.updateMask- Mask to control which fields get updated. Updates all if not present.- Throws:
ApiException- if the remote call fails
-
updateSshPublicKey
public final OsLoginProto.SshPublicKey updateSshPublicKey(String name, OsLoginProto.SshPublicKey sshPublicKey, com.google.protobuf.FieldMask updateMask) Updates an SSH public key and returns the profile information. This method supports patch semantics.Sample 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 name = FingerprintName.of("[USER]", "[FINGERPRINT]").toString(); OsLoginProto.SshPublicKey sshPublicKey = OsLoginProto.SshPublicKey.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); OsLoginProto.SshPublicKey response = osLoginServiceClient.updateSshPublicKey(name, sshPublicKey, updateMask); }- Parameters:
name- Required. The fingerprint of the public key to update. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format `users/{user}/sshPublicKeys/{fingerprint}`.sshPublicKey- Required. The SSH public key and expiration time.updateMask- Mask to control which fields get updated. Updates all if not present.- Throws:
ApiException- if the remote call fails
-
updateSshPublicKey
Updates an SSH public key and returns the profile information. This method supports patch semantics.Sample 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()) { UpdateSshPublicKeyRequest request = UpdateSshPublicKeyRequest.newBuilder() .setName(FingerprintName.of("[USER]", "[FINGERPRINT]").toString()) .setSshPublicKey(OsLoginProto.SshPublicKey.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); OsLoginProto.SshPublicKey response = osLoginServiceClient.updateSshPublicKey(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateSshPublicKeyCallable
public final UnaryCallable<UpdateSshPublicKeyRequest,OsLoginProto.SshPublicKey> updateSshPublicKeyCallable()Updates an SSH public key and returns the profile information. This method supports patch semantics.Sample 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()) { UpdateSshPublicKeyRequest request = UpdateSshPublicKeyRequest.newBuilder() .setName(FingerprintName.of("[USER]", "[FINGERPRINT]").toString()) .setSshPublicKey(OsLoginProto.SshPublicKey.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<OsLoginProto.SshPublicKey> future = osLoginServiceClient.updateSshPublicKeyCallable().futureCall(request); // Do something. OsLoginProto.SshPublicKey response = future.get(); } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-