RecycleBin

Client

class RecycleBin.Client

A low-level client representing Amazon Recycle Bin

This is the Recycle Bin API Reference . This documentation provides descriptions and syntax for each of the actions and data types in Recycle Bin.

Recycle Bin is a snapshot recovery feature that enables you to restore accidentally deleted snapshots. When using Recycle Bin, if your snapshots are deleted, they are retained in the Recycle Bin for a time period that you specify.

You can restore a snapshot from the Recycle Bin at any time before its retention period expires. After you restore a snapshot from the Recycle Bin, the snapshot is removed from the Recycle Bin, and you can then use it in the same way you use any other snapshot in your account. If the retention period expires and the snapshot is not restored, the snapshot is permanently deleted from the Recycle Bin and is no longer available for recovery. For more information about Recycle Bin, see Recycle Bin in the Amazon EC2 User Guide .

client = session.create_client('rbin')

These are the available methods:

can_paginate(operation_name)

Check if an operation can be paginated.

Parameters

operation_name (string) – The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you’d normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator("create_foo").

Returns

True if the operation can be paginated, False otherwise.

create_rule(**kwargs)

Creates a Recycle Bin retention rule. For more information, see Create Recycle Bin retention rules in the Amazon EC2 User Guide .

See also: AWS API Documentation

Request Syntax

response = client.create_rule(
    RetentionPeriod={
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    Description='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    ResourceType='EBS_SNAPSHOT',
    ResourceTags=[
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ]
)
Parameters
  • RetentionPeriod (dict) –

    [REQUIRED]

    Information about the retention period for which the retention rule is to retain resources.

    • RetentionPeriodValue (integer) – [REQUIRED]

      The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .

    • RetentionPeriodUnit (string) – [REQUIRED]

      The unit of time in which the retention period is measured. Currently, only DAYS is supported.

  • Description (string) – A brief description for the retention rule.

  • Tags (list) –

    Information about the tags to assign to the retention rule.

    • (dict) –

      Information about the tags assigned to a Recycle Bin retention rule.

      • Key (string) – [REQUIRED]

        The tag key.

      • Value (string) – [REQUIRED]

        The tag value.

  • ResourceType (string) –

    [REQUIRED]

    The resource type to be retained by the retention rule. Currently, only Amazon EBS snapshots are supported.

  • ResourceTags (list) –

    Information about the resource tags to use to identify resources that are to be retained by the retention rule. The retention rule retains only deleted snapshots that have one or more of the specified tag key and value pairs. If a snapshot is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.

    You can add the same tag key and value pair to a maximum or five retention rules.

    • (dict) –

      Information about a resource tag used to identify resources that are to be retained by a Recycle Bin retention rule.

      • ResourceTagKey (string) – [REQUIRED]

        The tag key.

      • ResourceTagValue (string) –

        The tag value.

Return type

dict

Returns

Response Syntax

{
    'Identifier': 'string',
    'RetentionPeriod': {
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    'Description': 'string',
    'Tags': [
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    'ResourceType': 'EBS_SNAPSHOT',
    'ResourceTags': [
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ],
    'Status': 'pending'|'available'
}

Response Structure

  • (dict) –

    • Identifier (string) –

      The unique identifier of the retention rule.

    • RetentionPeriod (dict) –

      Information about the retention period for which a retention rule is to retain resources.

      • RetentionPeriodValue (integer) –

        The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .

      • RetentionPeriodUnit (string) –

        The unit of time in which the retention period is measured. Currently, only DAYS is supported.

    • Description (string) –

      The retention rule description.

    • Tags (list) –

      The tags assigned to the retention rule.

      • (dict) –

        Information about the tags assigned to a Recycle Bin retention rule.

        • Key (string) –

          The tag key.

        • Value (string) –

          The tag value.

    • ResourceType (string) –

      The resource type retained by the retention rule.

    • ResourceTags (list) –

      Information about the resource tags used to identify resources that are retained by the retention rule.

      • (dict) –

        Information about a resource tag used to identify resources that are to be retained by a Recycle Bin retention rule.

        • ResourceTagKey (string) –

          The tag key.

        • ResourceTagValue (string) –

          The tag value.

    • Status (string) –

      The state of the retention rule. Only retention rules that are in the available state retain snapshots.

Exceptions

delete_rule(**kwargs)

Deletes a Recycle Bin retention rule. For more information, see Delete Recycle Bin retention rules in the Amazon EC2 User Guide .

See also: AWS API Documentation

Request Syntax

response = client.delete_rule(
    Identifier='string'
)
Parameters

Identifier (string) –

[REQUIRED]

The unique ID of the retention rule to delete.

Return type

dict

Returns

Response Syntax

{}

Response Structure

  • (dict) –

Exceptions

get_paginator(operation_name)

Create a paginator for an operation.

Parameters

operation_name (string) – The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you’d normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator("create_foo").

Raises

OperationNotPageableError – Raised if the operation is not pageable. You can use the client.can_paginate method to check if an operation is pageable.

Return type

L{botocore.paginate.Paginator}

Returns

A paginator object.

get_rule(**kwargs)

Gets information about a Recycle Bin retention rule.

See also: AWS API Documentation

Request Syntax

response = client.get_rule(
    Identifier='string'
)
Parameters

Identifier (string) –

[REQUIRED]

The unique ID of the retention rule.

Return type

dict

Returns

Response Syntax

{
    'Identifier': 'string',
    'Description': 'string',
    'ResourceType': 'EBS_SNAPSHOT',
    'RetentionPeriod': {
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    'ResourceTags': [
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ],
    'Status': 'pending'|'available'
}

Response Structure

  • (dict) –

    • Identifier (string) –

      The unique ID of the retention rule.

    • Description (string) –

      The description assigned to the retention rule.

    • ResourceType (string) –

      The resource type retained by the retention rule. Currently, only Amazon EBS snapshots are supported.

    • RetentionPeriod (dict) –

      Information about the period for which the retention rule retains resources.

      • RetentionPeriodValue (integer) –

        The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .

      • RetentionPeriodUnit (string) –

        The unit of time in which the retention period is measured. Currently, only DAYS is supported.

    • ResourceTags (list) –

      The resource tags used to identify resources that are to be retained by the retention rule.

      • (dict) –

        Information about a resource tag used to identify resources that are to be retained by a Recycle Bin retention rule.

        • ResourceTagKey (string) –

          The tag key.

        • ResourceTagValue (string) –

          The tag value.

    • Status (string) –

      The state of the retention rule. Only retention rules that are in the available state retain snapshots.

Exceptions

get_waiter(waiter_name)

Returns an object that can wait for some condition.

Parameters

waiter_name (str) – The name of the waiter to get. See the waiters section of the service docs for a list of available waiters.

Returns

The specified waiter object.

Return type

botocore.waiter.Waiter

list_rules(**kwargs)

Lists the Recycle Bin retention rules in the Region.

See also: AWS API Documentation

Request Syntax

response = client.list_rules(
    MaxResults=123,
    NextToken='string',
    ResourceType='EBS_SNAPSHOT',
    ResourceTags=[
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ]
)
Parameters
  • MaxResults (integer) – The maximum number of results to return for the request in a single page. The remaining results can be seen by sending another request with the returned nextToken value. This value can be between 5 and 500. If maxResults is given a larger value than 500, you receive an error.

  • NextToken (string) – The token to use to retrieve the next page of results.

  • ResourceType (string) –

    [REQUIRED]

    The resource type retained by the retention rule. Only retention rules that retain the specified resource type are listed.

  • ResourceTags (list) –

    The tags used to identify resources that are to be retained by the retention rule.

    • (dict) –

      Information about a resource tag used to identify resources that are to be retained by a Recycle Bin retention rule.

      • ResourceTagKey (string) – [REQUIRED]

        The tag key.

      • ResourceTagValue (string) –

        The tag value.

Return type

dict

Returns

Response Syntax

{
    'Rules': [
        {
            'Identifier': 'string',
            'Description': 'string',
            'RetentionPeriod': {
                'RetentionPeriodValue': 123,
                'RetentionPeriodUnit': 'DAYS'
            }
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) –

    • Rules (list) –

      Information about the retention rules.

      • (dict) –

        Information about a Recycle Bin retention rule.

        • Identifier (string) –

          The unique ID of the retention rule.

        • Description (string) –

          The description for the retention rule.

        • RetentionPeriod (dict) –

          Information about the retention period for which the retention rule retains resources

          • RetentionPeriodValue (integer) –

            The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .

          • RetentionPeriodUnit (string) –

            The unit of time in which the retention period is measured. Currently, only DAYS is supported.

    • NextToken (string) –

      The token to use to retrieve the next page of results. This value is null when there are no more results to return.

Exceptions

list_tags_for_resource(**kwargs)

Lists the tags assigned a specific resource.

See also: AWS API Documentation

Request Syntax

response = client.list_tags_for_resource(
    ResourceArn='string'
)
Parameters

ResourceArn (string) –

[REQUIRED]

The Amazon Resource Name (ARN) of the resource for which to list the tags.

Return type

dict

Returns

Response Syntax

{
    'Tags': [
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
}

Response Structure

  • (dict) –

    • Tags (list) –

      Information about the tags assigned to the resource.

      • (dict) –

        Information about the tags assigned to a Recycle Bin retention rule.

        • Key (string) –

          The tag key.

        • Value (string) –

          The tag value.

Exceptions

tag_resource(**kwargs)

Assigns tags to the specified resource.

See also: AWS API Documentation

Request Syntax

response = client.tag_resource(
    ResourceArn='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
Parameters
  • ResourceArn (string) –

    [REQUIRED]

    The Amazon Resource Name (ARN) of the resource to which to assign the tags.

  • Tags (list) –

    [REQUIRED]

    Information about the tags to assign to the resource.

    • (dict) –

      Information about the tags assigned to a Recycle Bin retention rule.

      • Key (string) – [REQUIRED]

        The tag key.

      • Value (string) – [REQUIRED]

        The tag value.

Return type

dict

Returns

Response Syntax

{}

Response Structure

  • (dict) –

Exceptions

untag_resource(**kwargs)

Unassigns a tag from a resource.

See also: AWS API Documentation

Request Syntax

response = client.untag_resource(
    ResourceArn='string',
    TagKeys=[
        'string',
    ]
)
Parameters
  • ResourceArn (string) –

    [REQUIRED]

    The Amazon Resource Name (ARN) of the resource from which to unassign the tags.

  • TagKeys (list) –

    [REQUIRED]

    Information about the tags to unassign from the resource.

    • (string) –

Return type

dict

Returns

Response Syntax

{}

Response Structure

  • (dict) –

Exceptions

update_rule(**kwargs)

Updates an existing Recycle Bin retention rule. For more information, see Update Recycle Bin retention rules in the Amazon EC2 User Guide .

See also: AWS API Documentation

Request Syntax

response = client.update_rule(
    Identifier='string',
    RetentionPeriod={
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    Description='string',
    ResourceType='EBS_SNAPSHOT',
    ResourceTags=[
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ]
)
Parameters
  • Identifier (string) –

    [REQUIRED]

    The unique ID of the retention rule to update.

  • RetentionPeriod (dict) –

    Information about the retention period for which the retention rule is to retain resources.

    • RetentionPeriodValue (integer) – [REQUIRED]

      The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .

    • RetentionPeriodUnit (string) – [REQUIRED]

      The unit of time in which the retention period is measured. Currently, only DAYS is supported.

  • Description (string) – The retention rule description.

  • ResourceType (string) – The resource type to be retained by the retention rule. Currently, only Amazon EBS snapshots are supported.

  • ResourceTags (list) –

    Information about the resource tags to use to identify resources that are to be retained by the retention rule. The retention rule retains only deleted snapshots that have one or more of the specified tag key and value pairs. If a snapshot is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.

    You can add the same tag key and value pair to a maximum or five retention rules.

    • (dict) –

      Information about a resource tag used to identify resources that are to be retained by a Recycle Bin retention rule.

      • ResourceTagKey (string) – [REQUIRED]

        The tag key.

      • ResourceTagValue (string) –

        The tag value.

Return type

dict

Returns

Response Syntax

{
    'Identifier': 'string',
    'RetentionPeriod': {
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    'Description': 'string',
    'ResourceType': 'EBS_SNAPSHOT',
    'ResourceTags': [
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ],
    'Status': 'pending'|'available'
}

Response Structure

  • (dict) –

    • Identifier (string) –

      The unique ID of the retention rule.

    • RetentionPeriod (dict) –

      Information about the retention period for which a retention rule is to retain resources.

      • RetentionPeriodValue (integer) –

        The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .

      • RetentionPeriodUnit (string) –

        The unit of time in which the retention period is measured. Currently, only DAYS is supported.

    • Description (string) –

      The retention rule description.

    • ResourceType (string) –

      The resource type retained by the retention rule.

    • ResourceTags (list) –

      Information about the resource tags used to identify resources that are retained by the retention rule.

      • (dict) –

        Information about a resource tag used to identify resources that are to be retained by a Recycle Bin retention rule.

        • ResourceTagKey (string) –

          The tag key.

        • ResourceTagValue (string) –

          The tag value.

    • Status (string) –

      The state of the retention rule. Only retention rules that are in the available state retain snapshots.

Exceptions

Client Exceptions

Client exceptions are available on a client instance via the exceptions property. For more detailed instructions and examples on the exact usage of client exceptions, see the error handling user guide.

The available client exceptions are:

class RecycleBin.Client.exceptions.InternalServerException

The service could not respond to the request due to an internal problem.

Example

try:
  ...
except client.exceptions.InternalServerException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) –

    The service could not respond to the request due to an internal problem.

    • Message (string) –

    • Error (dict) – Normalized access to common exception attributes.

      • Code (string) – An identifier specifying the exception type.

      • Message (string) – A descriptive message explaining why the exception occured.

class RecycleBin.Client.exceptions.ResourceNotFoundException

The specified resource was not found.

Example

try:
  ...
except client.exceptions.ResourceNotFoundException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Reason': 'RULE_NOT_FOUND',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) –

    The specified resource was not found.

    • Message (string) –

    • Reason (string) –

      The reason for the exception.

    • Error (dict) – Normalized access to common exception attributes.

      • Code (string) – An identifier specifying the exception type.

      • Message (string) – A descriptive message explaining why the exception occured.

class RecycleBin.Client.exceptions.ServiceQuotaExceededException

The request would cause a service quota for the number of tags per resource to be exceeded.

Example

try:
  ...
except client.exceptions.ServiceQuotaExceededException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Reason': 'SERVICE_QUOTA_EXCEEDED',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) –

    The request would cause a service quota for the number of tags per resource to be exceeded.

    • Message (string) –

    • Reason (string) –

      The reason for the exception.

    • Error (dict) – Normalized access to common exception attributes.

      • Code (string) – An identifier specifying the exception type.

      • Message (string) – A descriptive message explaining why the exception occured.

class RecycleBin.Client.exceptions.ValidationException

One or more of the parameters in the request is not valid.

Example

try:
  ...
except client.exceptions.ValidationException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Reason': 'INVALID_PAGE_TOKEN'|'INVALID_PARAMETER_VALUE',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) –

    One or more of the parameters in the request is not valid.

    • Message (string) –

    • Reason (string) –

      The reason for the exception.

    • Error (dict) – Normalized access to common exception attributes.

      • Code (string) – An identifier specifying the exception type.

      • Message (string) – A descriptive message explaining why the exception occured.

Paginators

The available paginators are:

class RecycleBin.Paginator.ListRules
paginator = client.get_paginator('list_rules')
paginate(**kwargs)

Creates an iterator that will paginate through responses from RecycleBin.Client.list_rules().

See also: AWS API Documentation

Request Syntax

response_iterator = paginator.paginate(
    ResourceType='EBS_SNAPSHOT',
    ResourceTags=[
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ],
    PaginationConfig={
        'MaxItems': 123,
        'PageSize': 123,
        'StartingToken': 'string'
    }
)
Parameters
  • ResourceType (string) –

    [REQUIRED]

    The resource type retained by the retention rule. Only retention rules that retain the specified resource type are listed.

  • ResourceTags (list) –

    The tags used to identify resources that are to be retained by the retention rule.

    • (dict) –

      Information about a resource tag used to identify resources that are to be retained by a Recycle Bin retention rule.

      • ResourceTagKey (string) – [REQUIRED]

        The tag key.

      • ResourceTagValue (string) –

        The tag value.

  • PaginationConfig (dict) –

    A dictionary that provides parameters to control pagination.

    • MaxItems (integer) –

      The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.

    • PageSize (integer) –

      The size of each page.

    • StartingToken (string) –

      A token to specify where to start paginating. This is the NextToken from a previous response.

Return type

dict

Returns

Response Syntax

{
    'Rules': [
        {
            'Identifier': 'string',
            'Description': 'string',
            'RetentionPeriod': {
                'RetentionPeriodValue': 123,
                'RetentionPeriodUnit': 'DAYS'
            }
        },
    ],

}

Response Structure

  • (dict) –

    • Rules (list) –

      Information about the retention rules.

      • (dict) –

        Information about a Recycle Bin retention rule.

        • Identifier (string) –

          The unique ID of the retention rule.

        • Description (string) –

          The description for the retention rule.

        • RetentionPeriod (dict) –

          Information about the retention period for which the retention rule retains resources

          • RetentionPeriodValue (integer) –

            The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .

          • RetentionPeriodUnit (string) –

            The unit of time in which the retention period is measured. Currently, only DAYS is supported.