Class SecretManagerServiceClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
Manages secrets and operations using those secrets. Implements a REST model with the following objects:
- [Secret][google.cloud.secrets.v1beta1.Secret]
- [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]
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 (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String secretId = "secretId945974251";
Secret secret = Secret.newBuilder().build();
Secret response = secretManagerServiceClient.createSecret(parent, secretId, secret);
}
Note: close() needs to be called on the SecretManagerServiceClient 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 |
|---|---|---|
ListSecrets |
Lists [Secrets][google.cloud.secrets.v1beta1.Secret]. |
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.
|
CreateSecret |
Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. |
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.
|
AddSecretVersion |
Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret]. |
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.
|
GetSecret |
Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret]. |
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.
|
UpdateSecret |
Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret]. |
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.
|
DeleteSecret |
Deletes a [Secret][google.cloud.secrets.v1beta1.Secret]. |
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.
|
ListSecretVersions |
Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret data. |
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.
|
GetSecretVersion |
Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. `projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. |
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.
|
AccessSecretVersion |
Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. This call returns the secret data. `projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. |
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.
|
DisableSecretVersion |
Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED]. |
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.
|
EnableSecretVersion |
Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED]. |
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.
|
DestroySecretVersion |
Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data. |
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.
|
SetIamPolicy |
Sets the access control policy on the specified secret. Replaces any existing policy. Permissions on [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] are enforced according to the policy set on the associated [Secret][google.cloud.secrets.v1beta1.Secret]. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetIamPolicy |
Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
TestIamPermissions |
Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListLocations |
Lists information about the supported locations for this service. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
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 SecretManagerServiceSettings 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
SecretManagerServiceSettings secretManagerServiceSettings =
SecretManagerServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create(secretManagerServiceSettings);
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
SecretManagerServiceSettings secretManagerServiceSettings =
SecretManagerServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create(secretManagerServiceSettings);
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
SecretManagerServiceSettings secretManagerServiceSettings =
SecretManagerServiceSettings.newHttpJsonBuilder().build();
SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create(secretManagerServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an instance of SecretManagerServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionAccesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].accessSecretVersion(String name) Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersionaddSecretVersion(AddSecretVersionRequest request) Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].final SecretVersionaddSecretVersion(SecretName parent, SecretPayload payload) Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].final SecretVersionaddSecretVersion(String parent, SecretPayload payload) Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].booleanawaitTermination(long duration, TimeUnit unit) final voidclose()static final SecretManagerServiceClientcreate()Constructs an instance of SecretManagerServiceClient with default settings.static final SecretManagerServiceClientcreate(SecretManagerServiceSettings settings) Constructs an instance of SecretManagerServiceClient, using the given settings.static final SecretManagerServiceClientConstructs an instance of SecretManagerServiceClient, using the given stub for making calls.final SecretcreateSecret(CreateSecretRequest request) Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].final SecretcreateSecret(ProjectName parent, String secretId, Secret secret) Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].final SecretcreateSecret(String parent, String secretId, Secret secret) Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].final voiddeleteSecret(DeleteSecretRequest request) Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].final voiddeleteSecret(SecretName name) Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].final voiddeleteSecret(String name) Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].final UnaryCallable<DeleteSecretRequest,com.google.protobuf.Empty> Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].final SecretVersionDestroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersionDestroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersiondestroySecretVersion(String name) Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersionDisables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersionDisables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersiondisableSecretVersion(String name) Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersionEnables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersionEnables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersionenableSecretVersion(String name) Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final PolicygetIamPolicy(GetIamPolicyRequest request) Gets the access control policy for a secret.Gets the access control policy for a secret.final LocationgetLocation(GetLocationRequest request) Gets information about a location.Gets information about a location.final SecretgetSecret(GetSecretRequest request) Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].final SecretgetSecret(SecretName name) Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].final SecretGets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].final UnaryCallable<GetSecretRequest,Secret> Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].final SecretVersiongetSecretVersion(GetSecretVersionRequest request) Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersionGets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].final SecretVersiongetSecretVersion(String name) Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].getStub()booleanbooleanlistLocations(ListLocationsRequest request) Lists information about the supported locations for this service.Lists information about the supported locations for this service.Lists information about the supported locations for this service.listSecrets(ListSecretsRequest request) Lists [Secrets][google.cloud.secrets.v1beta1.Secret].listSecrets(ProjectName parent) Lists [Secrets][google.cloud.secrets.v1beta1.Secret].listSecrets(String parent) Lists [Secrets][google.cloud.secrets.v1beta1.Secret].Lists [Secrets][google.cloud.secrets.v1beta1.Secret].Lists [Secrets][google.cloud.secrets.v1beta1.Secret].Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].listSecretVersions(SecretName parent) Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].listSecretVersions(String parent) Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].final UnaryCallable<ListSecretVersionsRequest,SecretManagerServiceClient.ListSecretVersionsPagedResponse> Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].final PolicysetIamPolicy(SetIamPolicyRequest request) Sets the access control policy on the specified secret.Sets the access control policy on the specified secret.voidshutdown()voidReturns permissions that a caller has for the specified secret.Returns permissions that a caller has for the specified secret.final SecretupdateSecret(Secret secret, com.google.protobuf.FieldMask updateMask) Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret].final SecretupdateSecret(UpdateSecretRequest request) Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret].Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret].
-
Constructor Details
-
SecretManagerServiceClient
Constructs an instance of SecretManagerServiceClient, 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
-
SecretManagerServiceClient
-
-
Method Details
-
create
Constructs an instance of SecretManagerServiceClient with default settings.- Throws:
IOException
-
create
public static final SecretManagerServiceClient create(SecretManagerServiceSettings settings) throws IOException Constructs an instance of SecretManagerServiceClient, 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 SecretManagerServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(SecretManagerServiceSettings). -
getSettings
-
getStub
-
listSecrets
Lists [Secrets][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ProjectName parent = ProjectName.of("[PROJECT]"); for (Secret element : secretManagerServiceClient.listSecrets(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The resource name of the project associated with the [Secrets][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`.- Throws:
ApiException- if the remote call fails
-
listSecrets
Lists [Secrets][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String parent = ProjectName.of("[PROJECT]").toString(); for (Secret element : secretManagerServiceClient.listSecrets(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The resource name of the project associated with the [Secrets][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`.- Throws:
ApiException- if the remote call fails
-
listSecrets
public final SecretManagerServiceClient.ListSecretsPagedResponse listSecrets(ListSecretsRequest request) Lists [Secrets][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ListSecretsRequest request = ListSecretsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Secret element : secretManagerServiceClient.listSecrets(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listSecretsPagedCallable
public final UnaryCallable<ListSecretsRequest,SecretManagerServiceClient.ListSecretsPagedResponse> listSecretsPagedCallable()Lists [Secrets][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ListSecretsRequest request = ListSecretsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Secret> future = secretManagerServiceClient.listSecretsPagedCallable().futureCall(request); // Do something. for (Secret element : future.get().iterateAll()) { // doThingsWith(element); } } -
listSecretsCallable
Lists [Secrets][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ListSecretsRequest request = ListSecretsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListSecretsResponse response = secretManagerServiceClient.listSecretsCallable().call(request); for (Secret element : response.getSecretsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
createSecret
Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ProjectName parent = ProjectName.of("[PROJECT]"); String secretId = "secretId945974251"; Secret secret = Secret.newBuilder().build(); Secret response = secretManagerServiceClient.createSecret(parent, secretId, secret); }- Parameters:
parent- Required. The resource name of the project to associate with the [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`.secretId- Required. This must be unique within the project.A secret ID is a string with a maximum length of 255 characters and can contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and underscore (`_`) characters.
secret- Required. A [Secret][google.cloud.secrets.v1beta1.Secret] with initial field values.- Throws:
ApiException- if the remote call fails
-
createSecret
Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String parent = ProjectName.of("[PROJECT]").toString(); String secretId = "secretId945974251"; Secret secret = Secret.newBuilder().build(); Secret response = secretManagerServiceClient.createSecret(parent, secretId, secret); }- Parameters:
parent- Required. The resource name of the project to associate with the [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`.secretId- Required. This must be unique within the project.A secret ID is a string with a maximum length of 255 characters and can contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and underscore (`_`) characters.
secret- Required. A [Secret][google.cloud.secrets.v1beta1.Secret] with initial field values.- Throws:
ApiException- if the remote call fails
-
createSecret
Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { CreateSecretRequest request = CreateSecretRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setSecretId("secretId945974251") .setSecret(Secret.newBuilder().build()) .build(); Secret response = secretManagerServiceClient.createSecret(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createSecretCallable
Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { CreateSecretRequest request = CreateSecretRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setSecretId("secretId945974251") .setSecret(Secret.newBuilder().build()) .build(); ApiFuture<Secret> future = secretManagerServiceClient.createSecretCallable().futureCall(request); // Do something. Secret response = future.get(); } -
addSecretVersion
Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SecretName parent = SecretName.of("[PROJECT]", "[SECRET]"); SecretPayload payload = SecretPayload.newBuilder().build(); SecretVersion response = secretManagerServiceClient.addSecretVersion(parent, payload); }- Parameters:
parent- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to associate with the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*`.payload- Required. The secret payload of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].- Throws:
ApiException- if the remote call fails
-
addSecretVersion
Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String parent = SecretName.of("[PROJECT]", "[SECRET]").toString(); SecretPayload payload = SecretPayload.newBuilder().build(); SecretVersion response = secretManagerServiceClient.addSecretVersion(parent, payload); }- Parameters:
parent- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to associate with the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*`.payload- Required. The secret payload of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].- Throws:
ApiException- if the remote call fails
-
addSecretVersion
Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { AddSecretVersionRequest request = AddSecretVersionRequest.newBuilder() .setParent(SecretName.of("[PROJECT]", "[SECRET]").toString()) .setPayload(SecretPayload.newBuilder().build()) .build(); SecretVersion response = secretManagerServiceClient.addSecretVersion(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
addSecretVersionCallable
Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { AddSecretVersionRequest request = AddSecretVersionRequest.newBuilder() .setParent(SecretName.of("[PROJECT]", "[SECRET]").toString()) .setPayload(SecretPayload.newBuilder().build()) .build(); ApiFuture<SecretVersion> future = secretManagerServiceClient.addSecretVersionCallable().futureCall(request); // Do something. SecretVersion response = future.get(); } -
getSecret
Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SecretName name = SecretName.of("[PROJECT]", "[SECRET]"); Secret response = secretManagerServiceClient.getSecret(name); }- Parameters:
name- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*/secrets/*`.- Throws:
ApiException- if the remote call fails
-
getSecret
Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String name = SecretName.of("[PROJECT]", "[SECRET]").toString(); Secret response = secretManagerServiceClient.getSecret(name); }- Parameters:
name- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*/secrets/*`.- Throws:
ApiException- if the remote call fails
-
getSecret
Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { GetSecretRequest request = GetSecretRequest.newBuilder() .setName(SecretName.of("[PROJECT]", "[SECRET]").toString()) .build(); Secret response = secretManagerServiceClient.getSecret(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getSecretCallable
Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { GetSecretRequest request = GetSecretRequest.newBuilder() .setName(SecretName.of("[PROJECT]", "[SECRET]").toString()) .build(); ApiFuture<Secret> future = secretManagerServiceClient.getSecretCallable().futureCall(request); // Do something. Secret response = future.get(); } -
updateSecret
Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { Secret secret = Secret.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); Secret response = secretManagerServiceClient.updateSecret(secret, updateMask); }- Parameters:
secret- Required. [Secret][google.cloud.secrets.v1beta1.Secret] with updated field values.updateMask- Required. Specifies the fields to be updated.- Throws:
ApiException- if the remote call fails
-
updateSecret
Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { UpdateSecretRequest request = UpdateSecretRequest.newBuilder() .setSecret(Secret.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Secret response = secretManagerServiceClient.updateSecret(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateSecretCallable
Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { UpdateSecretRequest request = UpdateSecretRequest.newBuilder() .setSecret(Secret.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Secret> future = secretManagerServiceClient.updateSecretCallable().futureCall(request); // Do something. Secret response = future.get(); } -
deleteSecret
Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SecretName name = SecretName.of("[PROJECT]", "[SECRET]"); secretManagerServiceClient.deleteSecret(name); }- Parameters:
name- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to delete in the format `projects/*/secrets/*`.- Throws:
ApiException- if the remote call fails
-
deleteSecret
Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String name = SecretName.of("[PROJECT]", "[SECRET]").toString(); secretManagerServiceClient.deleteSecret(name); }- Parameters:
name- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to delete in the format `projects/*/secrets/*`.- Throws:
ApiException- if the remote call fails
-
deleteSecret
Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { DeleteSecretRequest request = DeleteSecretRequest.newBuilder() .setName(SecretName.of("[PROJECT]", "[SECRET]").toString()) .build(); secretManagerServiceClient.deleteSecret(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteSecretCallable
Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { DeleteSecretRequest request = DeleteSecretRequest.newBuilder() .setName(SecretName.of("[PROJECT]", "[SECRET]").toString()) .build(); ApiFuture<Empty> future = secretManagerServiceClient.deleteSecretCallable().futureCall(request); // Do something. future.get(); } -
listSecretVersions
public final SecretManagerServiceClient.ListSecretVersionsPagedResponse listSecretVersions(SecretName parent) Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret data.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SecretName parent = SecretName.of("[PROJECT]", "[SECRET]"); for (SecretVersion element : secretManagerServiceClient.listSecretVersions(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] associated with the [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] to list, in the format `projects/*/secrets/*`.- Throws:
ApiException- if the remote call fails
-
listSecretVersions
public final SecretManagerServiceClient.ListSecretVersionsPagedResponse listSecretVersions(String parent) Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret data.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String parent = SecretName.of("[PROJECT]", "[SECRET]").toString(); for (SecretVersion element : secretManagerServiceClient.listSecretVersions(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] associated with the [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] to list, in the format `projects/*/secrets/*`.- Throws:
ApiException- if the remote call fails
-
listSecretVersions
public final SecretManagerServiceClient.ListSecretVersionsPagedResponse listSecretVersions(ListSecretVersionsRequest request) Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret data.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ListSecretVersionsRequest request = ListSecretVersionsRequest.newBuilder() .setParent(SecretName.of("[PROJECT]", "[SECRET]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (SecretVersion element : secretManagerServiceClient.listSecretVersions(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listSecretVersionsPagedCallable
public final UnaryCallable<ListSecretVersionsRequest,SecretManagerServiceClient.ListSecretVersionsPagedResponse> listSecretVersionsPagedCallable()Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret data.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ListSecretVersionsRequest request = ListSecretVersionsRequest.newBuilder() .setParent(SecretName.of("[PROJECT]", "[SECRET]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<SecretVersion> future = secretManagerServiceClient.listSecretVersionsPagedCallable().futureCall(request); // Do something. for (SecretVersion element : future.get().iterateAll()) { // doThingsWith(element); } } -
listSecretVersionsCallable
public final UnaryCallable<ListSecretVersionsRequest,ListSecretVersionsResponse> listSecretVersionsCallable()Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion]. This call does not return secret data.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ListSecretVersionsRequest request = ListSecretVersionsRequest.newBuilder() .setParent(SecretName.of("[PROJECT]", "[SECRET]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListSecretVersionsResponse response = secretManagerServiceClient.listSecretVersionsCallable().call(request); for (SecretVersion element : response.getVersionsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
getSecretVersion
Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]"); SecretVersion response = secretManagerServiceClient.getSecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].- Throws:
ApiException- if the remote call fails
-
getSecretVersion
Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString(); SecretVersion response = secretManagerServiceClient.getSecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].- Throws:
ApiException- if the remote call fails
-
getSecretVersion
Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { GetSecretVersionRequest request = GetSecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); SecretVersion response = secretManagerServiceClient.getSecretVersion(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getSecretVersionCallable
Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { GetSecretVersionRequest request = GetSecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); ApiFuture<SecretVersion> future = secretManagerServiceClient.getSecretVersionCallable().futureCall(request); // Do something. SecretVersion response = future.get(); } -
accessSecretVersion
Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. This call returns the secret data.`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]"); AccessSecretVersionResponse response = secretManagerServiceClient.accessSecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*/versions/*`.- Throws:
ApiException- if the remote call fails
-
accessSecretVersion
Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. This call returns the secret data.`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString(); AccessSecretVersionResponse response = secretManagerServiceClient.accessSecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format `projects/*/secrets/*/versions/*`.- Throws:
ApiException- if the remote call fails
-
accessSecretVersion
Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. This call returns the secret data.`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { AccessSecretVersionRequest request = AccessSecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); AccessSecretVersionResponse response = secretManagerServiceClient.accessSecretVersion(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
accessSecretVersionCallable
public final UnaryCallable<AccessSecretVersionRequest,AccessSecretVersionResponse> accessSecretVersionCallable()Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. This call returns the secret data.`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { AccessSecretVersionRequest request = AccessSecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); ApiFuture<AccessSecretVersionResponse> future = secretManagerServiceClient.accessSecretVersionCallable().futureCall(request); // Do something. AccessSecretVersionResponse response = future.get(); } -
disableSecretVersion
Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]"); SecretVersion response = secretManagerServiceClient.disableSecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to disable in the format `projects/*/secrets/*/versions/*`.- Throws:
ApiException- if the remote call fails
-
disableSecretVersion
Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString(); SecretVersion response = secretManagerServiceClient.disableSecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to disable in the format `projects/*/secrets/*/versions/*`.- Throws:
ApiException- if the remote call fails
-
disableSecretVersion
Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { DisableSecretVersionRequest request = DisableSecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); SecretVersion response = secretManagerServiceClient.disableSecretVersion(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
disableSecretVersionCallable
public final UnaryCallable<DisableSecretVersionRequest,SecretVersion> disableSecretVersionCallable()Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { DisableSecretVersionRequest request = DisableSecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); ApiFuture<SecretVersion> future = secretManagerServiceClient.disableSecretVersionCallable().futureCall(request); // Do something. SecretVersion response = future.get(); } -
enableSecretVersion
Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]"); SecretVersion response = secretManagerServiceClient.enableSecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to enable in the format `projects/*/secrets/*/versions/*`.- Throws:
ApiException- if the remote call fails
-
enableSecretVersion
Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString(); SecretVersion response = secretManagerServiceClient.enableSecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to enable in the format `projects/*/secrets/*/versions/*`.- Throws:
ApiException- if the remote call fails
-
enableSecretVersion
Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { EnableSecretVersionRequest request = EnableSecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); SecretVersion response = secretManagerServiceClient.enableSecretVersion(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
enableSecretVersionCallable
Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { EnableSecretVersionRequest request = EnableSecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); ApiFuture<SecretVersion> future = secretManagerServiceClient.enableSecretVersionCallable().futureCall(request); // Do something. SecretVersion response = future.get(); } -
destroySecretVersion
Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data.
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]"); SecretVersion response = secretManagerServiceClient.destroySecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to destroy in the format `projects/*/secrets/*/versions/*`.- Throws:
ApiException- if the remote call fails
-
destroySecretVersion
Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data.
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString(); SecretVersion response = secretManagerServiceClient.destroySecretVersion(name); }- Parameters:
name- Required. The resource name of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to destroy in the format `projects/*/secrets/*/versions/*`.- Throws:
ApiException- if the remote call fails
-
destroySecretVersion
Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data.
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { DestroySecretVersionRequest request = DestroySecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); SecretVersion response = secretManagerServiceClient.destroySecretVersion(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
destroySecretVersionCallable
public final UnaryCallable<DestroySecretVersionRequest,SecretVersion> destroySecretVersionCallable()Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data.
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { DestroySecretVersionRequest request = DestroySecretVersionRequest.newBuilder() .setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString()) .build(); ApiFuture<SecretVersion> future = secretManagerServiceClient.destroySecretVersionCallable().futureCall(request); // Do something. SecretVersion response = future.get(); } -
setIamPolicy
Sets the access control policy on the specified secret. Replaces any existing policy.Permissions on [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] are enforced according to the policy set on the associated [Secret][google.cloud.secrets.v1beta1.Secret].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource(SecretName.of("[PROJECT]", "[SECRET]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Policy response = secretManagerServiceClient.setIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
setIamPolicyCallable
Sets the access control policy on the specified secret. Replaces any existing policy.Permissions on [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] are enforced according to the policy set on the associated [Secret][google.cloud.secrets.v1beta1.Secret].
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() .setResource(SecretName.of("[PROJECT]", "[SECRET]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Policy> future = secretManagerServiceClient.setIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
getIamPolicy
Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource(SecretName.of("[PROJECT]", "[SECRET]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); Policy response = secretManagerServiceClient.getIamPolicy(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getIamPolicyCallable
Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() .setResource(SecretName.of("[PROJECT]", "[SECRET]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); ApiFuture<Policy> future = secretManagerServiceClient.getIamPolicyCallable().futureCall(request); // Do something. Policy response = future.get(); } -
testIamPermissions
Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error.Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource(SecretName.of("[PROJECT]", "[SECRET]").toString()) .addAllPermissions(new ArrayList<String>()) .build(); TestIamPermissionsResponse response = secretManagerServiceClient.testIamPermissions(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
testIamPermissionsCallable
public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error.Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() .setResource(SecretName.of("[PROJECT]", "[SECRET]").toString()) .addAllPermissions(new ArrayList<String>()) .build(); ApiFuture<TestIamPermissionsResponse> future = secretManagerServiceClient.testIamPermissionsCallable().futureCall(request); // Do something. TestIamPermissionsResponse response = future.get(); } -
listLocations
public final SecretManagerServiceClient.ListLocationsPagedResponse listLocations(ListLocationsRequest request) Lists information about the supported locations for this service.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Location element : secretManagerServiceClient.listLocations(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listLocationsPagedCallable
public final UnaryCallable<ListLocationsRequest,SecretManagerServiceClient.ListLocationsPagedResponse> listLocationsPagedCallable()Lists information about the supported locations for this service.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Location> future = secretManagerServiceClient.listLocationsPagedCallable().futureCall(request); // Do something. for (Location element : future.get().iterateAll()) { // doThingsWith(element); } } -
listLocationsCallable
Lists information about the supported locations for this service.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { ListLocationsRequest request = ListLocationsRequest.newBuilder() .setName("name3373707") .setFilter("filter-1274492040") .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListLocationsResponse response = secretManagerServiceClient.listLocationsCallable().call(request); for (Location element : response.getLocationsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
getLocation
Gets information about a location.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); Location response = secretManagerServiceClient.getLocation(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getLocationCallable
Gets information about a location.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 (SecretManagerServiceClient secretManagerServiceClient = SecretManagerServiceClient.create()) { GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); ApiFuture<Location> future = secretManagerServiceClient.getLocationCallable().futureCall(request); // Do something. Location 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
-