Skip to content

SecretsManagerClient#

Index > SecretsManager > SecretsManagerClient

Auto-generated documentation for SecretsManager type annotations stubs module mypy-boto3-secretsmanager.

SecretsManagerClient#

Type annotations and code completion for boto3.client("secretsmanager"). boto3 documentation

# SecretsManagerClient usage example

from boto3.session import Session
from mypy_boto3_secretsmanager.client import SecretsManagerClient

def get_secretsmanager_client() -> SecretsManagerClient:
    return Session().client("secretsmanager")

Exceptions#

boto3 client exceptions are generated in runtime. This class provides code completion for boto3.client("secretsmanager").exceptions structure.

# Exceptions.exceptions usage example

client = boto3.client("secretsmanager")

try:
    do_something(client)
except (
    client.exceptions.ClientError,
    client.exceptions.DecryptionFailure,
    client.exceptions.EncryptionFailure,
    client.exceptions.InternalServiceError,
    client.exceptions.InvalidNextTokenException,
    client.exceptions.InvalidParameterException,
    client.exceptions.InvalidRequestException,
    client.exceptions.LimitExceededException,
    client.exceptions.MalformedPolicyDocumentException,
    client.exceptions.PreconditionNotMetException,
    client.exceptions.PublicPolicyException,
    client.exceptions.ResourceExistsException,
    client.exceptions.ResourceNotFoundException,
) as e:
    print(e)
# Exceptions.exceptions type checking example

from mypy_boto3_secretsmanager.client import Exceptions

def handle_error(exc: Exceptions.ClientError) -> None:
    ...

Methods#

batch_get_secret_value#

Retrieves the contents of the encrypted fields SecretString or SecretBinary for up to 20 secrets.

Type annotations and code completion for boto3.client("secretsmanager").batch_get_secret_value method. boto3 documentation

# batch_get_secret_value method definition

def batch_get_secret_value(
    self,
    *,
    SecretIdList: Sequence[str] = ...,
    Filters: Sequence[FilterTypeDef] = ...,  # (1)
    MaxResults: int = ...,
    NextToken: str = ...,
) -> BatchGetSecretValueResponseTypeDef:  # (2)
    ...
  1. See FilterTypeDef
  2. See BatchGetSecretValueResponseTypeDef
# batch_get_secret_value method usage example with argument unpacking

kwargs: BatchGetSecretValueRequestRequestTypeDef = {  # (1)
    "SecretIdList": ...,
}

parent.batch_get_secret_value(**kwargs)
  1. See BatchGetSecretValueRequestRequestTypeDef

can_paginate#

Check if an operation can be paginated.

Type annotations and code completion for boto3.client("secretsmanager").can_paginate method. boto3 documentation

# can_paginate method definition

def can_paginate(
    self,
    operation_name: str,
) -> bool:
    ...

cancel_rotate_secret#

Turns off automatic rotation, and if a rotation is currently in progress, cancels the rotation.

Type annotations and code completion for boto3.client("secretsmanager").cancel_rotate_secret method. boto3 documentation

# cancel_rotate_secret method definition

def cancel_rotate_secret(
    self,
    *,
    SecretId: str,
) -> CancelRotateSecretResponseTypeDef:  # (1)
    ...
  1. See CancelRotateSecretResponseTypeDef
# cancel_rotate_secret method usage example with argument unpacking

kwargs: CancelRotateSecretRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.cancel_rotate_secret(**kwargs)
  1. See CancelRotateSecretRequestRequestTypeDef

close#

Closes underlying endpoint connections.

Type annotations and code completion for boto3.client("secretsmanager").close method. boto3 documentation

# close method definition

def close(
    self,
) -> None:
    ...

create_secret#

Creates a new secret.

Type annotations and code completion for boto3.client("secretsmanager").create_secret method. boto3 documentation

# create_secret method definition

def create_secret(
    self,
    *,
    Name: str,
    ClientRequestToken: str = ...,
    Description: str = ...,
    KmsKeyId: str = ...,
    SecretBinary: Union[str, bytes, IO[Any], StreamingBody] = ...,
    SecretString: str = ...,
    Tags: Sequence[TagTypeDef] = ...,  # (1)
    AddReplicaRegions: Sequence[ReplicaRegionTypeTypeDef] = ...,  # (2)
    ForceOverwriteReplicaSecret: bool = ...,
) -> CreateSecretResponseTypeDef:  # (3)
    ...
  1. See TagTypeDef
  2. See ReplicaRegionTypeTypeDef
  3. See CreateSecretResponseTypeDef
# create_secret method usage example with argument unpacking

kwargs: CreateSecretRequestRequestTypeDef = {  # (1)
    "Name": ...,
}

parent.create_secret(**kwargs)
  1. See CreateSecretRequestRequestTypeDef

delete_resource_policy#

Deletes the resource-based permission policy attached to the secret.

Type annotations and code completion for boto3.client("secretsmanager").delete_resource_policy method. boto3 documentation

# delete_resource_policy method definition

def delete_resource_policy(
    self,
    *,
    SecretId: str,
) -> DeleteResourcePolicyResponseTypeDef:  # (1)
    ...
  1. See DeleteResourcePolicyResponseTypeDef
# delete_resource_policy method usage example with argument unpacking

kwargs: DeleteResourcePolicyRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.delete_resource_policy(**kwargs)
  1. See DeleteResourcePolicyRequestRequestTypeDef

delete_secret#

Deletes a secret and all of its versions.

Type annotations and code completion for boto3.client("secretsmanager").delete_secret method. boto3 documentation

# delete_secret method definition

def delete_secret(
    self,
    *,
    SecretId: str,
    RecoveryWindowInDays: int = ...,
    ForceDeleteWithoutRecovery: bool = ...,
) -> DeleteSecretResponseTypeDef:  # (1)
    ...
  1. See DeleteSecretResponseTypeDef
# delete_secret method usage example with argument unpacking

kwargs: DeleteSecretRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.delete_secret(**kwargs)
  1. See DeleteSecretRequestRequestTypeDef

describe_secret#

Retrieves the details of a secret.

Type annotations and code completion for boto3.client("secretsmanager").describe_secret method. boto3 documentation

# describe_secret method definition

def describe_secret(
    self,
    *,
    SecretId: str,
) -> DescribeSecretResponseTypeDef:  # (1)
    ...
  1. See DescribeSecretResponseTypeDef
# describe_secret method usage example with argument unpacking

kwargs: DescribeSecretRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.describe_secret(**kwargs)
  1. See DescribeSecretRequestRequestTypeDef

generate_presigned_url#

Generate a presigned url given a client, its method, and arguments.

Type annotations and code completion for boto3.client("secretsmanager").generate_presigned_url method. boto3 documentation

# generate_presigned_url method definition

def generate_presigned_url(
    self,
    ClientMethod: str,
    Params: Mapping[str, Any] = ...,
    ExpiresIn: int = 3600,
    HttpMethod: str = ...,
) -> str:
    ...

get_random_password#

Generates a random password.

Type annotations and code completion for boto3.client("secretsmanager").get_random_password method. boto3 documentation

# get_random_password method definition

def get_random_password(
    self,
    *,
    PasswordLength: int = ...,
    ExcludeCharacters: str = ...,
    ExcludeNumbers: bool = ...,
    ExcludePunctuation: bool = ...,
    ExcludeUppercase: bool = ...,
    ExcludeLowercase: bool = ...,
    IncludeSpace: bool = ...,
    RequireEachIncludedType: bool = ...,
) -> GetRandomPasswordResponseTypeDef:  # (1)
    ...
  1. See GetRandomPasswordResponseTypeDef
# get_random_password method usage example with argument unpacking

kwargs: GetRandomPasswordRequestRequestTypeDef = {  # (1)
    "PasswordLength": ...,
}

parent.get_random_password(**kwargs)
  1. See GetRandomPasswordRequestRequestTypeDef

get_resource_policy#

Retrieves the JSON text of the resource-based policy document attached to the secret.

Type annotations and code completion for boto3.client("secretsmanager").get_resource_policy method. boto3 documentation

# get_resource_policy method definition

def get_resource_policy(
    self,
    *,
    SecretId: str,
) -> GetResourcePolicyResponseTypeDef:  # (1)
    ...
  1. See GetResourcePolicyResponseTypeDef
# get_resource_policy method usage example with argument unpacking

kwargs: GetResourcePolicyRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.get_resource_policy(**kwargs)
  1. See GetResourcePolicyRequestRequestTypeDef

get_secret_value#

Retrieves the contents of the encrypted fields SecretString or SecretBinary from the specified version of a secret, whichever contains content.

Type annotations and code completion for boto3.client("secretsmanager").get_secret_value method. boto3 documentation

# get_secret_value method definition

def get_secret_value(
    self,
    *,
    SecretId: str,
    VersionId: str = ...,
    VersionStage: str = ...,
) -> GetSecretValueResponseTypeDef:  # (1)
    ...
  1. See GetSecretValueResponseTypeDef
# get_secret_value method usage example with argument unpacking

kwargs: GetSecretValueRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.get_secret_value(**kwargs)
  1. See GetSecretValueRequestRequestTypeDef

list_secret_version_ids#

Lists the versions of a secret.

Type annotations and code completion for boto3.client("secretsmanager").list_secret_version_ids method. boto3 documentation

# list_secret_version_ids method definition

def list_secret_version_ids(
    self,
    *,
    SecretId: str,
    MaxResults: int = ...,
    NextToken: str = ...,
    IncludeDeprecated: bool = ...,
) -> ListSecretVersionIdsResponseTypeDef:  # (1)
    ...
  1. See ListSecretVersionIdsResponseTypeDef
# list_secret_version_ids method usage example with argument unpacking

kwargs: ListSecretVersionIdsRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.list_secret_version_ids(**kwargs)
  1. See ListSecretVersionIdsRequestRequestTypeDef

list_secrets#

Lists the secrets that are stored by Secrets Manager in the Amazon Web Services account, not including secrets that are marked for deletion.

Type annotations and code completion for boto3.client("secretsmanager").list_secrets method. boto3 documentation

# list_secrets method definition

def list_secrets(
    self,
    *,
    IncludePlannedDeletion: bool = ...,
    MaxResults: int = ...,
    NextToken: str = ...,
    Filters: Sequence[FilterTypeDef] = ...,  # (1)
    SortOrder: SortOrderTypeType = ...,  # (2)
) -> ListSecretsResponseTypeDef:  # (3)
    ...
  1. See FilterTypeDef
  2. See SortOrderTypeType
  3. See ListSecretsResponseTypeDef
# list_secrets method usage example with argument unpacking

kwargs: ListSecretsRequestRequestTypeDef =