Class SecretManagerServiceClient

java.lang.Object
com.google.cloud.secretmanager.v1beta2.SecretManagerServiceClient
All Implemented Interfaces:
BackgroundResource, AutoCloseable

@BetaApi @Generated("by gapic-generator-java") public class SecretManagerServiceClient extends Object implements BackgroundResource
Service Description: Secret Manager Service

Manages secrets and operations using those secrets. Implements a REST model with the following objects:

  • [Secret][google.cloud.secretmanager.v1beta2.Secret]
  • [SecretVersion][google.cloud.secretmanager.v1beta2.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()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   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().

Methods
Method Description Method Variants

ListSecrets

Lists [Secrets][google.cloud.secretmanager.v1beta2.Secret].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listSecrets(ListSecretsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listSecrets(LocationName parent)

  • listSecrets(ProjectName parent)

  • listSecrets(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listSecretsPagedCallable()

  • listSecretsCallable()

CreateSecret

Creates a new [Secret][google.cloud.secretmanager.v1beta2.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1beta2.SecretVersion].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createSecret(CreateSecretRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createSecret(LocationName parent, String secretId, Secret secret)

  • createSecret(ProjectName parent, String secretId, Secret secret)

  • createSecret(String parent, String secretId, Secret secret)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createSecretCallable()

AddSecretVersion

Creates a new [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secretmanager.v1beta2.Secret].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • addSecretVersion(AddSecretVersionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • addSecretVersion(SecretName parent, SecretPayload payload)

  • addSecretVersion(String parent, SecretPayload payload)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • addSecretVersionCallable()

GetSecret

Gets metadata for a given [Secret][google.cloud.secretmanager.v1beta2.Secret].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSecret(GetSecretRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSecret(SecretName name)

  • getSecret(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSecretCallable()

UpdateSecret

Updates metadata of an existing [Secret][google.cloud.secretmanager.v1beta2.Secret].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateSecret(UpdateSecretRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateSecret(Secret secret, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateSecretCallable()

DeleteSecret

Deletes a [Secret][google.cloud.secretmanager.v1beta2.Secret].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteSecret(DeleteSecretRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteSecret(SecretName name)

  • deleteSecret(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteSecretCallable()

ListSecretVersions

Lists [SecretVersions][google.cloud.secretmanager.v1beta2.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.

  • listSecretVersions(ListSecretVersionsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listSecretVersions(SecretName parent)

  • listSecretVersions(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listSecretVersionsPagedCallable()

  • listSecretVersionsCallable()

GetSecretVersion

Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

`projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSecretVersion(GetSecretVersionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSecretVersion(SecretVersionName name)

  • getSecretVersion(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSecretVersionCallable()

AccessSecretVersion

Accesses a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. This call returns the secret data.

`projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • accessSecretVersion(AccessSecretVersionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • accessSecretVersion(SecretVersionName name)

  • accessSecretVersion(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • accessSecretVersionCallable()

DisableSecretVersion

Disables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DISABLED][google.cloud.secretmanager.v1beta2.SecretVersion.State.DISABLED].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • disableSecretVersion(DisableSecretVersionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • disableSecretVersion(SecretVersionName name)

  • disableSecretVersion(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • disableSecretVersionCallable()

EnableSecretVersion

Enables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [ENABLED][google.cloud.secretmanager.v1beta2.SecretVersion.State.ENABLED].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • enableSecretVersion(EnableSecretVersionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • enableSecretVersion(SecretVersionName name)

  • enableSecretVersion(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • enableSecretVersionCallable()

DestroySecretVersion

Destroys a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DESTROYED][google.cloud.secretmanager.v1beta2.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.

  • destroySecretVersion(DestroySecretVersionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • destroySecretVersion(SecretVersionName name)

  • destroySecretVersion(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • destroySecretVersionCallable()

SetIamPolicy

Sets the access control policy on the specified secret. Replaces any existing policy.

Permissions on [SecretVersions][google.cloud.secretmanager.v1beta2.SecretVersion] are enforced according to the policy set on the associated [Secret][google.cloud.secretmanager.v1beta2.Secret].

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • setIamPolicy(SetIamPolicyRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • setIamPolicyCallable()

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.

  • getIamPolicy(GetIamPolicyRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getIamPolicyCallable()

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.

  • testIamPermissions(TestIamPermissionsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • testIamPermissionsCallable()

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.

  • listLocations(ListLocationsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listLocationsPagedCallable()

  • listLocationsCallable()

GetLocation

Gets information about a location.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getLocation(GetLocationRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getLocationCallable()

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.

  • Constructor Details

    • SecretManagerServiceClient

      protected SecretManagerServiceClient(SecretManagerServiceSettings settings) throws IOException
      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

      protected SecretManagerServiceClient(SecretManagerServiceStub stub)
  • Method Details

    • create

      public static final SecretManagerServiceClient create() throws IOException
      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

      public static final SecretManagerServiceClient create(SecretManagerServiceStub stub)
      Constructs an instance of SecretManagerServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(SecretManagerServiceSettings).
    • getSettings

      public final SecretManagerServiceSettings getSettings()
    • getStub

      public SecretManagerServiceStub getStub()
    • listSecrets

      Lists [Secrets][google.cloud.secretmanager.v1beta2.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()) {
         LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
         for (Secret element : secretManagerServiceClient.listSecrets(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The resource name of the project associated with the [Secrets][google.cloud.secretmanager.v1beta2.Secret], in the format `projects/*` or `projects/*/locations/*`
      Throws:
      ApiException - if the remote call fails
    • listSecrets

      Lists [Secrets][google.cloud.secretmanager.v1beta2.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.secretmanager.v1beta2.Secret], in the format `projects/*` or `projects/*/locations/*`
      Throws:
      ApiException - if the remote call fails
    • listSecrets

      Lists [Secrets][google.cloud.secretmanager.v1beta2.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.secretmanager.v1beta2.Secret], in the format `projects/*` or `projects/*/locations/*`
      Throws:
      ApiException - if the remote call fails
    • listSecrets

      Lists [Secrets][google.cloud.secretmanager.v1beta2.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")
                 .setFilter("filter-1274492040")
                 .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

      Lists [Secrets][google.cloud.secretmanager.v1beta2.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")
                 .setFilter("filter-1274492040")
                 .build();
         ApiFuture<Secret> future =
             secretManagerServiceClient.listSecretsPagedCallable().futureCall(request);
         // Do something.
         for (Secret element : future.get().iterateAll()) {
           // doThingsWith(element);
         }
       }
       
    • listSecretsCallable

      public final UnaryCallable<ListSecretsRequest,ListSecretsResponse> listSecretsCallable()
      Lists [Secrets][google.cloud.secretmanager.v1beta2.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")
                 .setFilter("filter-1274492040")
                 .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

      public final Secret createSecret(LocationName parent, String secretId, Secret secret)
      Creates a new [Secret][google.cloud.secretmanager.v1beta2.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1beta2.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()) {
         LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
         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.secretmanager.v1beta2.Secret], in the format `projects/*` or `projects/*/locations/*`.
      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.secretmanager.v1beta2.Secret] with initial field values.
      Throws:
      ApiException - if the remote call fails
    • createSecret

      public final Secret createSecret(ProjectName parent, String secretId, Secret secret)
      Creates a new [Secret][google.cloud.secretmanager.v1beta2.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1beta2.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.secretmanager.v1beta2.Secret], in the format `projects/*` or `projects/*/locations/*`.
      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.secretmanager.v1beta2.Secret] with initial field values.
      Throws:
      ApiException - if the remote call fails
    • createSecret

      public final Secret createSecret(String parent, String secretId, Secret secret)
      Creates a new [Secret][google.cloud.secretmanager.v1beta2.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1beta2.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.secretmanager.v1beta2.Secret], in the format `projects/*` or `projects/*/locations/*`.
      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.secretmanager.v1beta2.Secret] with initial field values.
      Throws:
      ApiException - if the remote call fails
    • createSecret

      public final Secret createSecret(CreateSecretRequest request)
      Creates a new [Secret][google.cloud.secretmanager.v1beta2.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1beta2.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

      public final UnaryCallable<CreateSecretRequest,Secret> createSecretCallable()
      Creates a new [Secret][google.cloud.secretmanager.v1beta2.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1beta2.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

      public final SecretVersion addSecretVersion(SecretName parent, SecretPayload payload)
      Creates a new [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]");
         SecretPayload payload = SecretPayload.newBuilder().build();
         SecretVersion response = secretManagerServiceClient.addSecretVersion(parent, payload);
       }
       
      Parameters:
      parent - Required. The resource name of the [Secret][google.cloud.secretmanager.v1beta2.Secret] to associate with the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
      payload - Required. The secret payload of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].
      Throws:
      ApiException - if the remote call fails
    • addSecretVersion

      public final SecretVersion addSecretVersion(String parent, SecretPayload payload)
      Creates a new [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[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.secretmanager.v1beta2.Secret] to associate with the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
      payload - Required. The secret payload of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].
      Throws:
      ApiException - if the remote call fails
    • addSecretVersion

      public final SecretVersion addSecretVersion(AddSecretVersionRequest request)
      Creates a new [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[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

      public final UnaryCallable<AddSecretVersionRequest,SecretVersion> addSecretVersionCallable()
      Creates a new [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString())
                 .setPayload(SecretPayload.newBuilder().build())
                 .build();
         ApiFuture<SecretVersion> future =
             secretManagerServiceClient.addSecretVersionCallable().futureCall(request);
         // Do something.
         SecretVersion response = future.get();
       }
       
    • getSecret

      public final Secret getSecret(SecretName name)
      Gets metadata for a given [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]");
         Secret response = secretManagerServiceClient.getSecret(name);
       }
       
      Parameters:
      name - Required. The resource name of the [Secret][google.cloud.secretmanager.v1beta2.Secret], in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
      Throws:
      ApiException - if the remote call fails
    • getSecret

      public final Secret getSecret(String name)
      Gets metadata for a given [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString();
         Secret response = secretManagerServiceClient.getSecret(name);
       }
       
      Parameters:
      name - Required. The resource name of the [Secret][google.cloud.secretmanager.v1beta2.Secret], in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
      Throws:
      ApiException - if the remote call fails
    • getSecret

      public final Secret getSecret(GetSecretRequest request)
      Gets metadata for a given [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[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

      public final UnaryCallable<GetSecretRequest,Secret> getSecretCallable()
      Gets metadata for a given [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString())
                 .build();
         ApiFuture<Secret> future = secretManagerServiceClient.getSecretCallable().futureCall(request);
         // Do something.
         Secret response = future.get();
       }
       
    • updateSecret

      public final Secret updateSecret(Secret secret, com.google.protobuf.FieldMask updateMask)
      Updates metadata of an existing [Secret][google.cloud.secretmanager.v1beta2.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.secretmanager.v1beta2.Secret] with updated field values.
      updateMask - Required. Specifies the fields to be updated.
      Throws:
      ApiException - if the remote call fails
    • updateSecret

      public final Secret updateSecret(UpdateSecretRequest request)
      Updates metadata of an existing [Secret][google.cloud.secretmanager.v1beta2.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

      public final UnaryCallable<UpdateSecretRequest,Secret> updateSecretCallable()
      Updates metadata of an existing [Secret][google.cloud.secretmanager.v1beta2.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

      public final void deleteSecret(SecretName name)
      Deletes a [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]");
         secretManagerServiceClient.deleteSecret(name);
       }
       
      Parameters:
      name - Required. The resource name of the [Secret][google.cloud.secretmanager.v1beta2.Secret] to delete in the format `projects/*/secrets/*`.
      Throws:
      ApiException - if the remote call fails
    • deleteSecret

      public final void deleteSecret(String name)
      Deletes a [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString();
         secretManagerServiceClient.deleteSecret(name);
       }
       
      Parameters:
      name - Required. The resource name of the [Secret][google.cloud.secretmanager.v1beta2.Secret] to delete in the format `projects/*/secrets/*`.
      Throws:
      ApiException - if the remote call fails
    • deleteSecret

      public final void deleteSecret(DeleteSecretRequest request)
      Deletes a [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString())
                 .setEtag("etag3123477")
                 .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

      public final UnaryCallable<DeleteSecretRequest,com.google.protobuf.Empty> deleteSecretCallable()
      Deletes a [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString())
                 .setEtag("etag3123477")
                 .build();
         ApiFuture<Empty> future =
             secretManagerServiceClient.deleteSecretCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • listSecretVersions

      Lists [SecretVersions][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]");
         for (SecretVersion element :
             secretManagerServiceClient.listSecretVersions(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The resource name of the [Secret][google.cloud.secretmanager.v1beta2.Secret] associated with the [SecretVersions][google.cloud.secretmanager.v1beta2.SecretVersion] to list, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
      Throws:
      ApiException - if the remote call fails
    • listSecretVersions

      public final SecretManagerServiceClient.ListSecretVersionsPagedResponse listSecretVersions(String parent)
      Lists [SecretVersions][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString();
         for (SecretVersion element :
             secretManagerServiceClient.listSecretVersions(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. The resource name of the [Secret][google.cloud.secretmanager.v1beta2.Secret] associated with the [SecretVersions][google.cloud.secretmanager.v1beta2.SecretVersion] to list, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
      Throws:
      ApiException - if the remote call fails
    • listSecretVersions

      Lists [SecretVersions][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .setFilter("filter-1274492040")
                 .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

      Lists [SecretVersions][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .setFilter("filter-1274492040")
                 .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.secretmanager.v1beta2.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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .setFilter("filter-1274492040")
                 .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

      public final SecretVersion getSecretVersion(SecretVersionName name)
      Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      `projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                 "[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
         SecretVersion response = secretManagerServiceClient.getSecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.

      `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Throws:
      ApiException - if the remote call fails
    • getSecretVersion

      public final SecretVersion getSecretVersion(String name)
      Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      `projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                     "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                 .toString();
         SecretVersion response = secretManagerServiceClient.getSecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.

      `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Throws:
      ApiException - if the remote call fails
    • getSecretVersion

      public final SecretVersion getSecretVersion(GetSecretVersionRequest request)
      Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      `projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[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

      public final UnaryCallable<GetSecretVersionRequest,SecretVersion> getSecretVersionCallable()
      Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      `projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                         .toString())
                 .build();
         ApiFuture<SecretVersion> future =
             secretManagerServiceClient.getSecretVersionCallable().futureCall(request);
         // Do something.
         SecretVersion response = future.get();
       }
       
    • accessSecretVersion

      public final AccessSecretVersionResponse accessSecretVersion(SecretVersionName name)
      Accesses a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. This call returns the secret data.

      `projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                 "[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
         AccessSecretVersionResponse response = secretManagerServiceClient.accessSecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.

      `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Throws:
      ApiException - if the remote call fails
    • accessSecretVersion

      public final AccessSecretVersionResponse accessSecretVersion(String name)
      Accesses a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. This call returns the secret data.

      `projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                     "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                 .toString();
         AccessSecretVersionResponse response = secretManagerServiceClient.accessSecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.

      `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Throws:
      ApiException - if the remote call fails
    • accessSecretVersion

      public final AccessSecretVersionResponse accessSecretVersion(AccessSecretVersionRequest request)
      Accesses a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion]. This call returns the secret data.

      `projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[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.secretmanager.v1beta2.SecretVersion]. This call returns the secret data.

      `projects/*/secrets/*/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                         .toString())
                 .build();
         ApiFuture<AccessSecretVersionResponse> future =
             secretManagerServiceClient.accessSecretVersionCallable().futureCall(request);
         // Do something.
         AccessSecretVersionResponse response = future.get();
       }
       
    • disableSecretVersion

      public final SecretVersion disableSecretVersion(SecretVersionName name)
      Disables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DISABLED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                 "[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
         SecretVersion response = secretManagerServiceClient.disableSecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to disable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
      Throws:
      ApiException - if the remote call fails
    • disableSecretVersion

      public final SecretVersion disableSecretVersion(String name)
      Disables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DISABLED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                     "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                 .toString();
         SecretVersion response = secretManagerServiceClient.disableSecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to disable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
      Throws:
      ApiException - if the remote call fails
    • disableSecretVersion

      public final SecretVersion disableSecretVersion(DisableSecretVersionRequest request)
      Disables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DISABLED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                         .toString())
                 .setEtag("etag3123477")
                 .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.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DISABLED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                         .toString())
                 .setEtag("etag3123477")
                 .build();
         ApiFuture<SecretVersion> future =
             secretManagerServiceClient.disableSecretVersionCallable().futureCall(request);
         // Do something.
         SecretVersion response = future.get();
       }
       
    • enableSecretVersion

      public final SecretVersion enableSecretVersion(SecretVersionName name)
      Enables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [ENABLED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                 "[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
         SecretVersion response = secretManagerServiceClient.enableSecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to enable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
      Throws:
      ApiException - if the remote call fails
    • enableSecretVersion

      public final SecretVersion enableSecretVersion(String name)
      Enables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [ENABLED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                     "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                 .toString();
         SecretVersion response = secretManagerServiceClient.enableSecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to enable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
      Throws:
      ApiException - if the remote call fails
    • enableSecretVersion

      public final SecretVersion enableSecretVersion(EnableSecretVersionRequest request)
      Enables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [ENABLED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                         .toString())
                 .setEtag("etag3123477")
                 .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

      public final UnaryCallable<EnableSecretVersionRequest,SecretVersion> enableSecretVersionCallable()
      Enables a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [ENABLED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                         .toString())
                 .setEtag("etag3123477")
                 .build();
         ApiFuture<SecretVersion> future =
             secretManagerServiceClient.enableSecretVersionCallable().futureCall(request);
         // Do something.
         SecretVersion response = future.get();
       }
       
    • destroySecretVersion

      public final SecretVersion destroySecretVersion(SecretVersionName name)
      Destroys a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DESTROYED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                 "[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
         SecretVersion response = secretManagerServiceClient.destroySecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to destroy in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
      Throws:
      ApiException - if the remote call fails
    • destroySecretVersion

      public final SecretVersion destroySecretVersion(String name)
      Destroys a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DESTROYED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                     "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                 .toString();
         SecretVersion response = secretManagerServiceClient.destroySecretVersion(name);
       }
       
      Parameters:
      name - Required. The resource name of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to destroy in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
      Throws:
      ApiException - if the remote call fails
    • destroySecretVersion

      public final SecretVersion destroySecretVersion(DestroySecretVersionRequest request)
      Destroys a [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DESTROYED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                         .toString())
                 .setEtag("etag3123477")
                 .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.secretmanager.v1beta2.SecretVersion].

      Sets the [state][google.cloud.secretmanager.v1beta2.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1beta2.SecretVersion] to [DESTROYED][google.cloud.secretmanager.v1beta2.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.ofProjectSecretSecretVersionName(
                             "[PROJECT]", "[SECRET]", "[SECRET_VERSION]")
                         .toString())
                 .setEtag("etag3123477")
                 .build();
         ApiFuture<SecretVersion> future =
             secretManagerServiceClient.destroySecretVersionCallable().futureCall(request);
         // Do something.
         SecretVersion response = future.get();
       }
       
    • setIamPolicy

      public final Policy setIamPolicy(SetIamPolicyRequest request)
      Sets the access control policy on the specified secret. Replaces any existing policy.

      Permissions on [SecretVersions][google.cloud.secretmanager.v1beta2.SecretVersion] are enforced according to the policy set on the associated [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[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

      public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()
      Sets the access control policy on the specified secret. Replaces any existing policy.

      Permissions on [SecretVersions][google.cloud.secretmanager.v1beta2.SecretVersion] are enforced according to the policy set on the associated [Secret][google.cloud.secretmanager.v1beta2.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.ofProjectSecretName("[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

      public final Policy getIamPolicy(GetIamPolicyRequest request)
      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.ofProjectSecretName("[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

      public final UnaryCallable<GetIamPolicyRequest,Policy> 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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString())
                 .setOptions(GetPolicyOptions.newBuilder().build())
                 .build();
         ApiFuture<Policy> future =
             secretManagerServiceClient.getIamPolicyCallable().futureCall(request);
         // Do something.
         Policy response = future.get();
       }
       
    • testIamPermissions

      public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)
      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.ofProjectSecretName("[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.ofProjectSecretName("[PROJECT]", "[SECRET]").toString())
                 .addAllPermissions(new ArrayList<String>())
                 .build();
         ApiFuture<TestIamPermissionsResponse> future =
             secretManagerServiceClient.testIamPermissionsCallable().futureCall(request);
         // Do something.
         TestIamPermissionsResponse response = future.get();
       }
       
    • listLocations

      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

      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

      public final UnaryCallable<ListLocationsRequest,ListLocationsResponse> 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

      public final Location getLocation(GetLocationRequest request)
      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

      public final UnaryCallable<GetLocationRequest,Location> 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:
      close in interface AutoCloseable
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface BackgroundResource
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface BackgroundResource
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface BackgroundResource
    • shutdownNow

      public void shutdownNow()
      Specified by:
      shutdownNow in interface BackgroundResource
    • awaitTermination

      public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface BackgroundResource
      Throws:
      InterruptedException