Skip to main content

SecretManagerClient

Struct SecretManagerClient 

Source
pub struct SecretManagerClient { /* private fields */ }
Expand description

Calls SecretManagerService.

Secrets, their versions, and the access to a version’s payload.

Implementations§

Source§

impl SecretManagerClient

Source

pub fn new(client: &Client) -> Self

Returns a client of SecretManagerService that sends its calls through client.

Source

pub fn service(&self) -> &Service

The endpoint the client sends its calls to, which also serves the operations its methods answer with.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for SecretManagerClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SecretManagerClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more