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

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.

Usage example
client = boto3.client("secretsmanager")

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

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

Methods

can_paginate

Check if an operation can be paginated.

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

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

Method definition
def cancel_rotate_secret(
    self,
    *,
    SecretId: str,
) -> CancelRotateSecretResponseTypeDef:  # (1)
    ...
  1. See CancelRotateSecretResponseTypeDef
Usage example with kwargs
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

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

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
Usage example with kwargs
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

Method definition
def delete_resource_policy(
    self,
    *,
    SecretId: str,
) -> DeleteResourcePolicyResponseTypeDef:  # (1)
    ...
  1. See DeleteResourcePolicyResponseTypeDef
Usage example with kwargs
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

Method definition
def delete_secret(
    self,
    *,
    SecretId: str,
    RecoveryWindowInDays: int = ...,
    ForceDeleteWithoutRecovery: bool = ...,
) -> DeleteSecretResponseTypeDef:  # (1)
    ...
  1. See DeleteSecretResponseTypeDef
Usage example with kwargs
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

Method definition
def describe_secret(
    self,
    *,
    SecretId: str,
) -> DescribeSecretResponseTypeDef:  # (1)
    ...
  1. See DescribeSecretResponseTypeDef
Usage example with kwargs
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

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

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
Usage example with kwargs
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

Method definition
def get_resource_policy(
    self,
    *,
    SecretId: str,
) -> GetResourcePolicyResponseTypeDef:  # (1)
    ...
  1. See GetResourcePolicyResponseTypeDef
Usage example with kwargs
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

Method definition
def get_secret_value(
    self,
    *,
    SecretId: str,
    VersionId: str = ...,
    VersionStage: str = ...,
) -> GetSecretValueResponseTypeDef:  # (1)
    ...
  1. See GetSecretValueResponseTypeDef
Usage example with kwargs
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

Method definition
def list_secret_version_ids(
    self,
    *,
    SecretId: str,
    MaxResults: int = ...,
    NextToken: str = ...,
    IncludeDeprecated: bool = ...,
) -> ListSecretVersionIdsResponseTypeDef:  # (1)
    ...
  1. See ListSecretVersionIdsResponseTypeDef
Usage example with kwargs
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

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
Usage example with kwargs
kwargs: ListSecretsRequestRequestTypeDef = {  # (1)
    "IncludePlannedDeletion": ...,
}

parent.list_secrets(**kwargs)
  1. See ListSecretsRequestRequestTypeDef

put_resource_policy

Attaches a resource-based permission policy to a secret.

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

Method definition
def put_resource_policy(
    self,
    *,
    SecretId: str,
    ResourcePolicy: str,
    BlockPublicPolicy: bool = ...,
) -> PutResourcePolicyResponseTypeDef:  # (1)
    ...
  1. See PutResourcePolicyResponseTypeDef
Usage example with kwargs
kwargs: PutResourcePolicyRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
    "ResourcePolicy": ...,
}

parent.put_resource_policy(**kwargs)
  1. See PutResourcePolicyRequestRequestTypeDef

put_secret_value

Creates a new version with a new encrypted secret value and attaches it to the secret.

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

Method definition
def put_secret_value(
    self,
    *,
    SecretId: str,
    ClientRequestToken: str = ...,
    SecretBinary: Union[str, bytes, IO[Any], StreamingBody] = ...,
    SecretString: str = ...,
    VersionStages: Sequence[str] = ...,
) -> PutSecretValueResponseTypeDef:  # (1)
    ...
  1. See PutSecretValueResponseTypeDef
Usage example with kwargs
kwargs: PutSecretValueRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.put_secret_value(**kwargs)
  1. See PutSecretValueRequestRequestTypeDef

remove_regions_from_replication

For a secret that is replicated to other Regions, deletes the secret replicas from the Regions you specify.

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

Method definition
def remove_regions_from_replication(
    self,
    *,
    SecretId: str,
    RemoveReplicaRegions: Sequence[str],
) -> RemoveRegionsFromReplicationResponseTypeDef:  # (1)
    ...
  1. See RemoveRegionsFromReplicationResponseTypeDef
Usage example with kwargs
kwargs: RemoveRegionsFromReplicationRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
    "RemoveReplicaRegions": ...,
}

parent.remove_regions_from_replication(**kwargs)
  1. See RemoveRegionsFromReplicationRequestRequestTypeDef

replicate_secret_to_regions

Replicates the secret to a new Regions.

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

Method definition
def replicate_secret_to_regions(
    self,
    *,
    SecretId: str,
    AddReplicaRegions: Sequence[ReplicaRegionTypeTypeDef],  # (1)
    ForceOverwriteReplicaSecret: bool = ...,
) -> ReplicateSecretToRegionsResponseTypeDef:  # (2)
    ...
  1. See ReplicaRegionTypeTypeDef
  2. See ReplicateSecretToRegionsResponseTypeDef
Usage example with kwargs
kwargs: ReplicateSecretToRegionsRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
    "AddReplicaRegions": ...,
}

parent.replicate_secret_to_regions(**kwargs)
  1. See ReplicateSecretToRegionsRequestRequestTypeDef

restore_secret

Cancels the scheduled deletion of a secret by removing the DeletedDate time stamp.

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

Method definition
def restore_secret(
    self,
    *,
    SecretId: str,
) -> RestoreSecretResponseTypeDef:  # (1)
    ...
  1. See RestoreSecretResponseTypeDef
Usage example with kwargs
kwargs: RestoreSecretRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.restore_secret(**kwargs)
  1. See RestoreSecretRequestRequestTypeDef

rotate_secret

Configures and starts the asynchronous process of rotating the secret.

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

Method definition
def rotate_secret(
    self,
    *,
    SecretId: str,
    ClientRequestToken: str = ...,
    RotationLambdaARN: str = ...,
    RotationRules: RotationRulesTypeTypeDef = ...,  # (1)
    RotateImmediately: bool = ...,
) -> RotateSecretResponseTypeDef:  # (2)
    ...
  1. See RotationRulesTypeTypeDef
  2. See RotateSecretResponseTypeDef
Usage example with kwargs
kwargs: RotateSecretRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.rotate_secret(**kwargs)
  1. See RotateSecretRequestRequestTypeDef

stop_replication_to_replica

Removes the link between the replica secret and the primary secret and promotes the replica to a primary secret in the replica Region.

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

Method definition
def stop_replication_to_replica(
    self,
    *,
    SecretId: str,
) -> StopReplicationToReplicaResponseTypeDef:  # (1)
    ...
  1. See StopReplicationToReplicaResponseTypeDef
Usage example with kwargs
kwargs: StopReplicationToReplicaRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.stop_replication_to_replica(**kwargs)
  1. See StopReplicationToReplicaRequestRequestTypeDef

tag_resource

Attaches tags to a secret.

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

Method definition
def tag_resource(
    self,
    *,
    SecretId: str,
    Tags: Sequence[TagTypeDef],  # (1)
) -> EmptyResponseMetadataTypeDef:  # (2)
    ...
  1. See TagTypeDef
  2. See EmptyResponseMetadataTypeDef
Usage example with kwargs
kwargs: TagResourceRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
    "Tags": ...,
}

parent.tag_resource(**kwargs)
  1. See TagResourceRequestRequestTypeDef

untag_resource

Removes specific tags from a secret.

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

Method definition
def untag_resource(
    self,
    *,
    SecretId: str,
    TagKeys: Sequence[str],
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
Usage example with kwargs
kwargs: UntagResourceRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
    "TagKeys": ...,
}

parent.untag_resource(**kwargs)
  1. See UntagResourceRequestRequestTypeDef

update_secret

Modifies the details of a secret, including metadata and the secret value.

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

Method definition
def update_secret(
    self,
    *,
    SecretId: str,
    ClientRequestToken: str = ...,
    Description: str = ...,
    KmsKeyId: str = ...,
    SecretBinary: Union[str, bytes, IO[Any], StreamingBody] = ...,
    SecretString: str = ...,
) -> UpdateSecretResponseTypeDef:  # (1)
    ...
  1. See UpdateSecretResponseTypeDef
Usage example with kwargs
kwargs: UpdateSecretRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
}

parent.update_secret(**kwargs)
  1. See UpdateSecretRequestRequestTypeDef

update_secret_version_stage

Modifies the staging labels attached to a version of a secret.

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

Method definition
def update_secret_version_stage(
    self,
    *,
    SecretId: str,
    VersionStage: str,
    RemoveFromVersionId: str = ...,
    MoveToVersionId: str = ...,
) -> UpdateSecretVersionStageResponseTypeDef:  # (1)
    ...
  1. See UpdateSecretVersionStageResponseTypeDef
Usage example with kwargs
kwargs: UpdateSecretVersionStageRequestRequestTypeDef = {  # (1)
    "SecretId": ...,
    "VersionStage": ...,
}

parent.update_secret_version_stage(**kwargs)
  1. See UpdateSecretVersionStageRequestRequestTypeDef

validate_resource_policy

Validates that a resource policy does not grant a wide range of principals access to your secret.

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

Method definition
def validate_resource_policy(
    self,
    *,
    ResourcePolicy: str,
    SecretId: str = ...,
) -> ValidateResourcePolicyResponseTypeDef:  # (1)
    ...
  1. See ValidateResourcePolicyResponseTypeDef
Usage example with kwargs
kwargs: ValidateResourcePolicyRequestRequestTypeDef = {  # (1)
    "ResourcePolicy": ...,
}

parent.validate_resource_policy(**kwargs)
  1. See ValidateResourcePolicyRequestRequestTypeDef

get_paginator

Type annotations and code completion for boto3.client("secretsmanager").get_paginator method with overloads.