pub struct SecretManagerClient { /* private fields */ }Expand description
Calls SecretManagerService.
Secrets, their versions, and the access to a version’s payload.
Implementations§
Source§impl SecretManagerClient
impl SecretManagerClient
Sourcepub fn new(client: &Client) -> Self
pub fn new(client: &Client) -> Self
Returns a client of SecretManagerService that sends its calls through client.
Sourcepub fn service(&self) -> &Service
pub fn service(&self) -> &Service
The endpoint the client sends its calls to, which also serves the operations its methods answer with.
Sourcepub fn with_options(&self, options: CallOptions) -> Self
pub fn with_options(&self, options: CallOptions) -> Self
The same client, whose calls are sent as options says instead of as the Client’s settings do, such as a mutation that must not be sent twice: .with_options(CallOptions::new().max_attempts(1)). See CallOptions.
Sourcepub async fn get_secret(
&self,
request: GetSecretRequest,
) -> Result<Secret, Error>
pub async fn get_secret( &self, request: GetSecretRequest, ) -> Result<Secret, Error>
Returns a secret, deleted or not, without any payload. Needs
secretmanager.secret.get on the secret.
Sourcepub async fn list_secrets(
&self,
request: ListSecretsRequest,
) -> Result<ListSecretsResponse, Error>
pub async fn list_secrets( &self, request: ListSecretsRequest, ) -> Result<ListSecretsResponse, Error>
Lists a project’s secrets in a region, ordered by name, without any
payload. Deleted ones are listed only when show_deleted is set, so a
page may hold fewer secrets than page_size and still be followed by
another. Needs secretmanager.secret.list on the project.
Sourcepub fn all_secrets(&self, request: ListSecretsRequest) -> Pages<Secret>
pub fn all_secrets(&self, request: ListSecretsRequest) -> Pages<Secret>
Returns everything list_secrets lists from request’s page on, fetching the next page as the stream reaches it. A page that fails ends the stream with its error.
Sourcepub async fn create_secret(
&self,
request: CreateSecretRequest,
) -> Result<Secret, Error>
pub async fn create_secret( &self, request: CreateSecretRequest, ) -> Result<Secret, Error>
Creates a secret, with no version yet, under the id the caller gives in
secret_id. Its payloads are encrypted under kms_key, or, when that is
left out, under the project’s default Secret Manager key in the region.
An id that a secret of the project and region has, including a deleted
one still in its recovery window, is refused with CONFLICT: restore
that secret with RestoreSecret, or delete it with force first. Needs
secretmanager.secret.create on the project.
Sourcepub async fn update_secret(
&self,
request: UpdateSecretRequest,
) -> Result<Secret, Error>
pub async fn update_secret( &self, request: UpdateSecretRequest, ) -> Result<Secret, Error>
Changes a secret’s tags, the one field it changes. Setting the tags the
secret already has succeeds and changes nothing. A deleted secret can’t
be changed: restore it first. Needs secretmanager.secret.update on the
secret.
Sourcepub async fn delete_secret(
&self,
request: DeleteSecretRequest,
) -> Result<Secret, Error>
pub async fn delete_secret( &self, request: DeleteSecretRequest, ) -> Result<Secret, Error>
Deletes a secret. By default the deletion is scheduled: the secret
becomes secret::State::Deleted at once, none of its versions can be accessed, its id
stays taken, and RestoreSecret brings it back until expire_time, after
pending_days. At expire_time the secret and every version are
destroyed for good and its id is free again. With force, the secret is
destroyed at once and can’t be restored. Deleting a deleted secret
without force succeeds and changes nothing. Needs
secretmanager.secret.delete on the secret, and with force
secretmanager.secret.force_delete as well.
Sourcepub async fn restore_secret(
&self,
request: RestoreSecretRequest,
) -> Result<Secret, Error>
pub async fn restore_secret( &self, request: RestoreSecretRequest, ) -> Result<Secret, Error>
Restores a deleted secret whose expire_time hasn’t passed: it becomes
secret::State::Active again, with every version in the state it had. Refused with
CONFLICT for a secret that isn’t deleted. Needs
secretmanager.secret.restore on the secret, which
secretmanager.secret.delete doesn’t include.
Sourcepub async fn add_secret_version(
&self,
request: AddSecretVersionRequest,
) -> Result<SecretVersion, Error>
pub async fn add_secret_version( &self, request: AddSecretVersionRequest, ) -> Result<SecretVersion, Error>
Adds a version holding payload to a secret, secret_version::State::Enabled, numbered one
above the secret’s newest version. It becomes latest. Refused with
BAD_REQUEST for a payload over 64 KiB, with CONFLICT for a deleted
secret, and with CONFLICT naming the key when the secret’s KMS key is
disabled or deleted. Needs secretmanager.secret_version.add on the
secret.
Sourcepub async fn access_secret_version(
&self,
request: AccessSecretVersionRequest,
) -> Result<AccessSecretVersionResponse, Error>
pub async fn access_secret_version( &self, request: AccessSecretVersionRequest, ) -> Result<AccessSecretVersionResponse, Error>
Returns a version’s payload, decrypted. versions/latest is the newest
secret_version::State::Enabled version. Refused with CONFLICT for a disabled or destroyed
version, for a deleted secret, and naming the key when the secret’s KMS
key is disabled or deleted; with NOT_FOUND for latest when no version
is enabled. Needs secretmanager.secret_version.access on the secret.
Sourcepub async fn get_secret_version(
&self,
request: GetSecretVersionRequest,
) -> Result<SecretVersion, Error>
pub async fn get_secret_version( &self, request: GetSecretVersionRequest, ) -> Result<SecretVersion, Error>
Returns a version, without its payload. versions/latest is the newest
secret_version::State::Enabled version. Needs secretmanager.secret_version.get on the
secret.
Sourcepub async fn list_secret_versions(
&self,
request: ListSecretVersionsRequest,
) -> Result<ListSecretVersionsResponse, Error>
pub async fn list_secret_versions( &self, request: ListSecretVersionsRequest, ) -> Result<ListSecretVersionsResponse, Error>
Lists a secret’s versions, newest first, without their payloads.
Destroyed ones are listed only when show_deleted is set. Needs
secretmanager.secret_version.list on the secret.
Sourcepub fn all_secret_versions(
&self,
request: ListSecretVersionsRequest,
) -> Pages<SecretVersion>
pub fn all_secret_versions( &self, request: ListSecretVersionsRequest, ) -> Pages<SecretVersion>
Returns everything list_secret_versions lists from request’s page on, fetching the next page as the stream reaches it. A page that fails ends the stream with its error.
Sourcepub async fn disable_secret_version(
&self,
request: DisableSecretVersionRequest,
) -> Result<SecretVersion, Error>
pub async fn disable_secret_version( &self, request: DisableSecretVersionRequest, ) -> Result<SecretVersion, Error>
Disables a version: AccessSecretVersion refuses it with CONFLICT, and
latest skips it, until it is enabled again. Disabling a disabled
version succeeds and changes nothing; a destroyed version is refused
with CONFLICT. Needs secretmanager.secret_version.disable on the
secret.
Sourcepub async fn enable_secret_version(
&self,
request: EnableSecretVersionRequest,
) -> Result<SecretVersion, Error>
pub async fn enable_secret_version( &self, request: EnableSecretVersionRequest, ) -> Result<SecretVersion, Error>
Enables a disabled version again. Enabling an enabled version succeeds
and changes nothing; a destroyed version is refused with CONFLICT.
Needs secretmanager.secret_version.enable on the secret.
Sourcepub async fn destroy_secret_version(
&self,
request: DestroySecretVersionRequest,
) -> Result<SecretVersion, Error>
pub async fn destroy_secret_version( &self, request: DestroySecretVersionRequest, ) -> Result<SecretVersion, Error>
Destroys a version’s payload at once and for good: the version becomes
secret_version::State::Deleted, nothing can read its payload again, and its number is never
given to another version. There is no recovery window and no undo.
Destroying a destroyed version succeeds and changes nothing. Needs
secretmanager.secret_version.destroy on the secret.