@BetaApi @Generated(value="by gapic-generator-java") public class SecretManagerServiceClient extends Object implements BackgroundResource
Manages secrets and operations using those secrets. Implements a REST model with the following objects:
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:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
String secretId = "secretId945974251";
Secret secret = Secret.newBuilder().build();
Secret response = secretManagerServiceClient.createSecret(parent, secretId, secret);
}
Note: close() needs to be called on the SecretManagerServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
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:
SecretManagerServiceSettings secretManagerServiceSettings =
SecretManagerServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create(secretManagerServiceSettings);
To customize the endpoint:
SecretManagerServiceSettings secretManagerServiceSettings =
SecretManagerServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create(secretManagerServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier and Type | Class and Description |
---|---|
static class |
SecretManagerServiceClient.ListSecretsFixedSizeCollection |
static class |
SecretManagerServiceClient.ListSecretsPage |
static class |
SecretManagerServiceClient.ListSecretsPagedResponse |
static class |
SecretManagerServiceClient.ListSecretVersionsFixedSizeCollection |
static class |
SecretManagerServiceClient.ListSecretVersionsPage |
static class |
SecretManagerServiceClient.ListSecretVersionsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
SecretManagerServiceClient(SecretManagerServiceSettings settings)
Constructs an instance of SecretManagerServiceClient, using the given settings.
|
protected |
SecretManagerServiceClient(SecretManagerServiceStub stub) |
Modifier and Type | Method and Description |
---|---|
AccessSecretVersionResponse |
accessSecretVersion(AccessSecretVersionRequest request)
Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
AccessSecretVersionResponse |
accessSecretVersion(SecretVersionName name)
Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
AccessSecretVersionResponse |
accessSecretVersion(String name)
Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
UnaryCallable<AccessSecretVersionRequest,AccessSecretVersionResponse> |
accessSecretVersionCallable()
Accesses a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
addSecretVersion(AddSecretVersionRequest request)
Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret
data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].
|
SecretVersion |
addSecretVersion(SecretName parent,
SecretPayload payload)
Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret
data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].
|
SecretVersion |
addSecretVersion(String parent,
SecretPayload payload)
Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret
data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].
|
UnaryCallable<AddSecretVersionRequest,SecretVersion> |
addSecretVersionCallable()
Creates a new [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] containing secret
data and attaches it to an existing [Secret][google.cloud.secrets.v1beta1.Secret].
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static SecretManagerServiceClient |
create()
Constructs an instance of SecretManagerServiceClient with default settings.
|
static SecretManagerServiceClient |
create(SecretManagerServiceSettings settings)
Constructs an instance of SecretManagerServiceClient, using the given settings.
|
static SecretManagerServiceClient |
create(SecretManagerServiceStub stub)
Constructs an instance of SecretManagerServiceClient, using the given stub for making calls.
|
Secret |
createSecret(CreateSecretRequest request)
Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no
[SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].
|
Secret |
createSecret(ProjectName parent,
String secretId,
Secret secret)
Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no
[SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].
|
Secret |
createSecret(String parent,
String secretId,
Secret secret)
Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no
[SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].
|
UnaryCallable<CreateSecretRequest,Secret> |
createSecretCallable()
Creates a new [Secret][google.cloud.secrets.v1beta1.Secret] containing no
[SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].
|
void |
deleteSecret(DeleteSecretRequest request)
Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].
|
void |
deleteSecret(SecretName name)
Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].
|
void |
deleteSecret(String name)
Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].
|
UnaryCallable<DeleteSecretRequest,Empty> |
deleteSecretCallable()
Deletes a [Secret][google.cloud.secrets.v1beta1.Secret].
|
SecretVersion |
destroySecretVersion(DestroySecretVersionRequest request)
Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
destroySecretVersion(SecretVersionName name)
Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
destroySecretVersion(String name)
Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
UnaryCallable<DestroySecretVersionRequest,SecretVersion> |
destroySecretVersionCallable()
Destroys a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
disableSecretVersion(DisableSecretVersionRequest request)
Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
disableSecretVersion(SecretVersionName name)
Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
disableSecretVersion(String name)
Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
UnaryCallable<DisableSecretVersionRequest,SecretVersion> |
disableSecretVersionCallable()
Disables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
enableSecretVersion(EnableSecretVersionRequest request)
Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
enableSecretVersion(SecretVersionName name)
Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
enableSecretVersion(String name)
Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
UnaryCallable<EnableSecretVersionRequest,SecretVersion> |
enableSecretVersionCallable()
Enables a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a secret.
|
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the access control policy for a secret.
|
Secret |
getSecret(GetSecretRequest request)
Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].
|
Secret |
getSecret(SecretName name)
Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].
|
Secret |
getSecret(String name)
Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].
|
UnaryCallable<GetSecretRequest,Secret> |
getSecretCallable()
Gets metadata for a given [Secret][google.cloud.secrets.v1beta1.Secret].
|
SecretVersion |
getSecretVersion(GetSecretVersionRequest request)
Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
getSecretVersion(SecretVersionName name)
Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretVersion |
getSecretVersion(String name)
Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
UnaryCallable<GetSecretVersionRequest,SecretVersion> |
getSecretVersionCallable()
Gets metadata for a [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretManagerServiceSettings |
getSettings() |
SecretManagerServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
SecretManagerServiceClient.ListSecretsPagedResponse |
listSecrets(ListSecretsRequest request)
Lists [Secrets][google.cloud.secrets.v1beta1.Secret].
|
SecretManagerServiceClient.ListSecretsPagedResponse |
listSecrets(ProjectName parent)
Lists [Secrets][google.cloud.secrets.v1beta1.Secret].
|
SecretManagerServiceClient.ListSecretsPagedResponse |
listSecrets(String parent)
Lists [Secrets][google.cloud.secrets.v1beta1.Secret].
|
UnaryCallable<ListSecretsRequest,ListSecretsResponse> |
listSecretsCallable()
Lists [Secrets][google.cloud.secrets.v1beta1.Secret].
|
UnaryCallable<ListSecretsRequest,SecretManagerServiceClient.ListSecretsPagedResponse> |
listSecretsPagedCallable()
Lists [Secrets][google.cloud.secrets.v1beta1.Secret].
|
SecretManagerServiceClient.ListSecretVersionsPagedResponse |
listSecretVersions(ListSecretVersionsRequest request)
Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretManagerServiceClient.ListSecretVersionsPagedResponse |
listSecretVersions(SecretName parent)
Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].
|
SecretManagerServiceClient.ListSecretVersionsPagedResponse |
listSecretVersions(String parent)
Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].
|
UnaryCallable<ListSecretVersionsRequest,ListSecretVersionsResponse> |
listSecretVersionsCallable()
Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].
|
UnaryCallable<ListSecretVersionsRequest,SecretManagerServiceClient.ListSecretVersionsPagedResponse> |
listSecretVersionsPagedCallable()
Lists [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion].
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy on the specified secret.
|
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the access control policy on the specified secret.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that a caller has for the specified secret.
|
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that a caller has for the specified secret.
|
Secret |
updateSecret(Secret secret,
FieldMask updateMask)
Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret].
|
Secret |
updateSecret(UpdateSecretRequest request)
Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret].
|
UnaryCallable<UpdateSecretRequest,Secret> |
updateSecretCallable()
Updates metadata of an existing [Secret][google.cloud.secrets.v1beta1.Secret].
|
protected SecretManagerServiceClient(SecretManagerServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected SecretManagerServiceClient(SecretManagerServiceStub stub)
public static final SecretManagerServiceClient create() throws IOException
IOException
public static final SecretManagerServiceClient create(SecretManagerServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final SecretManagerServiceClient create(SecretManagerServiceStub stub)
public final SecretManagerServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public SecretManagerServiceStub getStub()
public final SecretManagerServiceClient.ListSecretsPagedResponse listSecrets(ProjectName parent)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Secret element : secretManagerServiceClient.listSecrets(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the project associated with the
[Secrets][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`.ApiException
- if the remote call failspublic final SecretManagerServiceClient.ListSecretsPagedResponse listSecrets(String parent)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
for (Secret element : secretManagerServiceClient.listSecrets(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the project associated with the
[Secrets][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`.ApiException
- if the remote call failspublic final SecretManagerServiceClient.ListSecretsPagedResponse listSecrets(ListSecretsRequest request)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
ListSecretsRequest request =
ListSecretsRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Secret element : secretManagerServiceClient.listSecrets(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListSecretsRequest,SecretManagerServiceClient.ListSecretsPagedResponse> listSecretsPagedCallable()
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
ListSecretsRequest request =
ListSecretsRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Secret> future =
secretManagerServiceClient.listSecretsPagedCallable().futureCall(request);
// Do something.
for (Secret element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListSecretsRequest,ListSecretsResponse> listSecretsCallable()
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
ListSecretsRequest request =
ListSecretsRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListSecretsResponse response =
secretManagerServiceClient.listSecretsCallable().call(request);
for (Secret element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Secret createSecret(ProjectName parent, String secretId, Secret secret)
Sample code:
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);
}
parent
- Required. The resource name of the project to associate with the
[Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`.secretId
- Required. This must be unique within the project.
A secret ID is a string with a maximum length of 255 characters and can contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and underscore (`_`) characters.
secret
- Required. A [Secret][google.cloud.secrets.v1beta1.Secret] with initial field
values.ApiException
- if the remote call failspublic final Secret createSecret(String parent, String secretId, Secret secret)
Sample code:
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);
}
parent
- Required. The resource name of the project to associate with the
[Secret][google.cloud.secrets.v1beta1.Secret], in the format `projects/*`.secretId
- Required. This must be unique within the project.
A secret ID is a string with a maximum length of 255 characters and can contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and underscore (`_`) characters.
secret
- Required. A [Secret][google.cloud.secrets.v1beta1.Secret] with initial field
values.ApiException
- if the remote call failspublic final Secret createSecret(CreateSecretRequest request)
Sample code:
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);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<CreateSecretRequest,Secret> createSecretCallable()
Sample code:
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();
}
public final SecretVersion addSecretVersion(SecretName parent, SecretPayload payload)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SecretName parent = SecretName.of("[PROJECT]", "[SECRET]");
SecretPayload payload = SecretPayload.newBuilder().build();
SecretVersion response = secretManagerServiceClient.addSecretVersion(parent, payload);
}
parent
- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret]
to associate with the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the
format `projects/*/secrets/*`.payload
- Required. The secret payload of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].ApiException
- if the remote call failspublic final SecretVersion addSecretVersion(String parent, SecretPayload payload)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String parent = SecretName.of("[PROJECT]", "[SECRET]").toString();
SecretPayload payload = SecretPayload.newBuilder().build();
SecretVersion response = secretManagerServiceClient.addSecretVersion(parent, payload);
}
parent
- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret]
to associate with the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the
format `projects/*/secrets/*`.payload
- Required. The secret payload of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].ApiException
- if the remote call failspublic final SecretVersion addSecretVersion(AddSecretVersionRequest request)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
AddSecretVersionRequest request =
AddSecretVersionRequest.newBuilder()
.setParent(SecretName.of("[PROJECT]", "[SECRET]").toString())
.setPayload(SecretPayload.newBuilder().build())
.build();
SecretVersion response = secretManagerServiceClient.addSecretVersion(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<AddSecretVersionRequest,SecretVersion> addSecretVersionCallable()
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
AddSecretVersionRequest request =
AddSecretVersionRequest.newBuilder()
.setParent(SecretName.of("[PROJECT]", "[SECRET]").toString())
.setPayload(SecretPayload.newBuilder().build())
.build();
ApiFuture<SecretVersion> future =
secretManagerServiceClient.addSecretVersionCallable().futureCall(request);
// Do something.
SecretVersion response = future.get();
}
public final Secret getSecret(SecretName name)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SecretName name = SecretName.of("[PROJECT]", "[SECRET]");
Secret response = secretManagerServiceClient.getSecret(name);
}
name
- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret],
in the format `projects/*/secrets/*`.ApiException
- if the remote call failspublic final Secret getSecret(String name)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String name = SecretName.of("[PROJECT]", "[SECRET]").toString();
Secret response = secretManagerServiceClient.getSecret(name);
}
name
- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret],
in the format `projects/*/secrets/*`.ApiException
- if the remote call failspublic final Secret getSecret(GetSecretRequest request)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
GetSecretRequest request =
GetSecretRequest.newBuilder()
.setName(SecretName.of("[PROJECT]", "[SECRET]").toString())
.build();
Secret response = secretManagerServiceClient.getSecret(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetSecretRequest,Secret> getSecretCallable()
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
GetSecretRequest request =
GetSecretRequest.newBuilder()
.setName(SecretName.of("[PROJECT]", "[SECRET]").toString())
.build();
ApiFuture<Secret> future = secretManagerServiceClient.getSecretCallable().futureCall(request);
// Do something.
Secret response = future.get();
}
public final Secret updateSecret(Secret secret, FieldMask updateMask)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
Secret secret = Secret.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Secret response = secretManagerServiceClient.updateSecret(secret, updateMask);
}
secret
- Required. [Secret][google.cloud.secrets.v1beta1.Secret] with updated field
values.updateMask
- Required. Specifies the fields to be updated.ApiException
- if the remote call failspublic final Secret updateSecret(UpdateSecretRequest request)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
UpdateSecretRequest request =
UpdateSecretRequest.newBuilder()
.setSecret(Secret.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Secret response = secretManagerServiceClient.updateSecret(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<UpdateSecretRequest,Secret> updateSecretCallable()
Sample code:
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();
}
public final void deleteSecret(SecretName name)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SecretName name = SecretName.of("[PROJECT]", "[SECRET]");
secretManagerServiceClient.deleteSecret(name);
}
name
- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to
delete in the format `projects/*/secrets/*`.ApiException
- if the remote call failspublic final void deleteSecret(String name)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String name = SecretName.of("[PROJECT]", "[SECRET]").toString();
secretManagerServiceClient.deleteSecret(name);
}
name
- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret] to
delete in the format `projects/*/secrets/*`.ApiException
- if the remote call failspublic final void deleteSecret(DeleteSecretRequest request)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
DeleteSecretRequest request =
DeleteSecretRequest.newBuilder()
.setName(SecretName.of("[PROJECT]", "[SECRET]").toString())
.build();
secretManagerServiceClient.deleteSecret(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<DeleteSecretRequest,Empty> deleteSecretCallable()
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
DeleteSecretRequest request =
DeleteSecretRequest.newBuilder()
.setName(SecretName.of("[PROJECT]", "[SECRET]").toString())
.build();
ApiFuture<Empty> future =
secretManagerServiceClient.deleteSecretCallable().futureCall(request);
// Do something.
future.get();
}
public final SecretManagerServiceClient.ListSecretVersionsPagedResponse listSecretVersions(SecretName parent)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SecretName parent = SecretName.of("[PROJECT]", "[SECRET]");
for (SecretVersion element :
secretManagerServiceClient.listSecretVersions(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret]
associated with the [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] to list,
in the format `projects/*/secrets/*`.ApiException
- if the remote call failspublic final SecretManagerServiceClient.ListSecretVersionsPagedResponse listSecretVersions(String parent)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String parent = SecretName.of("[PROJECT]", "[SECRET]").toString();
for (SecretVersion element :
secretManagerServiceClient.listSecretVersions(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the [Secret][google.cloud.secrets.v1beta1.Secret]
associated with the [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] to list,
in the format `projects/*/secrets/*`.ApiException
- if the remote call failspublic final SecretManagerServiceClient.ListSecretVersionsPagedResponse listSecretVersions(ListSecretVersionsRequest request)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
ListSecretVersionsRequest request =
ListSecretVersionsRequest.newBuilder()
.setParent(SecretName.of("[PROJECT]", "[SECRET]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (SecretVersion element :
secretManagerServiceClient.listSecretVersions(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListSecretVersionsRequest,SecretManagerServiceClient.ListSecretVersionsPagedResponse> listSecretVersionsPagedCallable()
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
ListSecretVersionsRequest request =
ListSecretVersionsRequest.newBuilder()
.setParent(SecretName.of("[PROJECT]", "[SECRET]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<SecretVersion> future =
secretManagerServiceClient.listSecretVersionsPagedCallable().futureCall(request);
// Do something.
for (SecretVersion element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListSecretVersionsRequest,ListSecretVersionsResponse> listSecretVersionsCallable()
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
ListSecretVersionsRequest request =
ListSecretVersionsRequest.newBuilder()
.setParent(SecretName.of("[PROJECT]", "[SECRET]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListSecretVersionsResponse response =
secretManagerServiceClient.listSecretVersionsCallable().call(request);
for (SecretVersion element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final SecretVersion getSecretVersion(SecretVersionName name)
`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
SecretVersion response = secretManagerServiceClient.getSecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format
`projects/*/secrets/*/versions/*`.
`projects/*/secrets/*/versions/latest` is an alias to the `latest`
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].ApiException
- if the remote call failspublic final SecretVersion getSecretVersion(String name)
`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString();
SecretVersion response = secretManagerServiceClient.getSecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format
`projects/*/secrets/*/versions/*`.
`projects/*/secrets/*/versions/latest` is an alias to the `latest`
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].ApiException
- if the remote call failspublic final SecretVersion getSecretVersion(GetSecretVersionRequest request)
`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
GetSecretVersionRequest request =
GetSecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
SecretVersion response = secretManagerServiceClient.getSecretVersion(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetSecretVersionRequest,SecretVersion> getSecretVersionCallable()
`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
GetSecretVersionRequest request =
GetSecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
ApiFuture<SecretVersion> future =
secretManagerServiceClient.getSecretVersionCallable().futureCall(request);
// Do something.
SecretVersion response = future.get();
}
public final AccessSecretVersionResponse accessSecretVersion(SecretVersionName name)
`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
AccessSecretVersionResponse response = secretManagerServiceClient.accessSecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format
`projects/*/secrets/*/versions/*`.ApiException
- if the remote call failspublic final AccessSecretVersionResponse accessSecretVersion(String name)
`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString();
AccessSecretVersionResponse response = secretManagerServiceClient.accessSecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] in the format
`projects/*/secrets/*/versions/*`.ApiException
- if the remote call failspublic final AccessSecretVersionResponse accessSecretVersion(AccessSecretVersionRequest request)
`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
AccessSecretVersionRequest request =
AccessSecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
AccessSecretVersionResponse response =
secretManagerServiceClient.accessSecretVersion(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<AccessSecretVersionRequest,AccessSecretVersionResponse> accessSecretVersionCallable()
`projects/*/secrets/*/versions/latest` is an alias to the `latest` [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
AccessSecretVersionRequest request =
AccessSecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
ApiFuture<AccessSecretVersionResponse> future =
secretManagerServiceClient.accessSecretVersionCallable().futureCall(request);
// Do something.
AccessSecretVersionResponse response = future.get();
}
public final SecretVersion disableSecretVersion(SecretVersionName name)
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
SecretVersion response = secretManagerServiceClient.disableSecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to disable in the format
`projects/*/secrets/*/versions/*`.ApiException
- if the remote call failspublic final SecretVersion disableSecretVersion(String name)
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString();
SecretVersion response = secretManagerServiceClient.disableSecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to disable in the format
`projects/*/secrets/*/versions/*`.ApiException
- if the remote call failspublic final SecretVersion disableSecretVersion(DisableSecretVersionRequest request)
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
DisableSecretVersionRequest request =
DisableSecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
SecretVersion response = secretManagerServiceClient.disableSecretVersion(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<DisableSecretVersionRequest,SecretVersion> disableSecretVersionCallable()
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DISABLED][google.cloud.secrets.v1beta1.SecretVersion.State.DISABLED].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
DisableSecretVersionRequest request =
DisableSecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
ApiFuture<SecretVersion> future =
secretManagerServiceClient.disableSecretVersionCallable().futureCall(request);
// Do something.
SecretVersion response = future.get();
}
public final SecretVersion enableSecretVersion(SecretVersionName name)
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
SecretVersion response = secretManagerServiceClient.enableSecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to enable in the format
`projects/*/secrets/*/versions/*`.ApiException
- if the remote call failspublic final SecretVersion enableSecretVersion(String name)
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString();
SecretVersion response = secretManagerServiceClient.enableSecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to enable in the format
`projects/*/secrets/*/versions/*`.ApiException
- if the remote call failspublic final SecretVersion enableSecretVersion(EnableSecretVersionRequest request)
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
EnableSecretVersionRequest request =
EnableSecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
SecretVersion response = secretManagerServiceClient.enableSecretVersion(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<EnableSecretVersionRequest,SecretVersion> enableSecretVersionCallable()
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
EnableSecretVersionRequest request =
EnableSecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
ApiFuture<SecretVersion> future =
secretManagerServiceClient.enableSecretVersionCallable().futureCall(request);
// Do something.
SecretVersion response = future.get();
}
public final SecretVersion destroySecretVersion(SecretVersionName name)
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data.
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SecretVersionName name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]");
SecretVersion response = secretManagerServiceClient.destroySecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to destroy in the format
`projects/*/secrets/*/versions/*`.ApiException
- if the remote call failspublic final SecretVersion destroySecretVersion(String name)
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data.
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
String name = SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString();
SecretVersion response = secretManagerServiceClient.destroySecretVersion(name);
}
name
- Required. The resource name of the
[SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to destroy in the format
`projects/*/secrets/*/versions/*`.ApiException
- if the remote call failspublic final SecretVersion destroySecretVersion(DestroySecretVersionRequest request)
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data.
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
DestroySecretVersionRequest request =
DestroySecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
SecretVersion response = secretManagerServiceClient.destroySecretVersion(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<DestroySecretVersionRequest,SecretVersion> destroySecretVersionCallable()
Sets the [state][google.cloud.secrets.v1beta1.SecretVersion.state] of the [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] to [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data.
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
DestroySecretVersionRequest request =
DestroySecretVersionRequest.newBuilder()
.setName(SecretVersionName.of("[PROJECT]", "[SECRET]", "[SECRET_VERSION]").toString())
.build();
ApiFuture<SecretVersion> future =
secretManagerServiceClient.destroySecretVersionCallable().futureCall(request);
// Do something.
SecretVersion response = future.get();
}
public final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Permissions on [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] are enforced according to the policy set on the associated [Secret][google.cloud.secrets.v1beta1.Secret].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(ProjectName.of("[PROJECT]").toString())
.setPolicy(Policy.newBuilder().build())
.build();
Policy response = secretManagerServiceClient.setIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
Permissions on [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] are enforced according to the policy set on the associated [Secret][google.cloud.secrets.v1beta1.Secret].
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(ProjectName.of("[PROJECT]").toString())
.setPolicy(Policy.newBuilder().build())
.build();
ApiFuture<Policy> future =
secretManagerServiceClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(ProjectName.of("[PROJECT]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = secretManagerServiceClient.getIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
Sample code:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(ProjectName.of("[PROJECT]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future =
secretManagerServiceClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
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:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(ProjectName.of("[PROJECT]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = secretManagerServiceClient.testIamPermissions(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
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:
try (SecretManagerServiceClient secretManagerServiceClient =
SecretManagerServiceClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(ProjectName.of("[PROJECT]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse> future =
secretManagerServiceClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2022 Google LLC. All rights reserved.