Table of Contents
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 resource recovery feature that enables you to restore accidentally deleted snapshots and EBS-backed AMIs. When using Recycle Bin, if your resources are deleted, they are retained in the Recycle Bin for a time period that you specify.
You can restore a resource from the Recycle Bin at any time before its retention period expires. After you restore a resource from the Recycle Bin, the resource is removed from the Recycle Bin, and you can then use it in the same way you use any other resource of that type in your account. If the retention period expires and the resource is not restored, the resource 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 Elastic Compute Cloud User Guide .
import boto3
client = boto3.client('rbin')
These are the available methods:
can_paginate()
close()
create_rule()
delete_rule()
get_paginator()
get_rule()
get_waiter()
list_rules()
list_tags_for_resource()
tag_resource()
untag_resource()
update_rule()
can_paginate
(operation_name)¶Check if an operation can be paginated.
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")
.True
if the operation can be paginated,
False
otherwise.close
()¶Closes underlying endpoint connections.
create_rule
(**kwargs)¶Creates a Recycle Bin retention rule. For more information, see Create Recycle Bin retention rules in the Amazon Elastic Compute Cloud 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'|'EC2_IMAGE',
ResourceTags=[
{
'ResourceTagKey': 'string',
'ResourceTagValue': 'string'
},
]
)
[REQUIRED]
Information about the retention period for which the retention rule is to retain resources.
The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .
The unit of time in which the retention period is measured. Currently, only DAYS
is supported.
Information about the tags to assign to the retention rule.
Information about the tags to assign to the retention rule.
The tag key.
The tag value.
[REQUIRED]
The resource type to be retained by the retention rule. Currently, only Amazon EBS snapshots and EBS-backed AMIs are supported. To retain snapshots, specify EBS_SNAPSHOT
. To retain EBS-backed AMIs, specify EC2_IMAGE
.
Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource 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.
To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.
Information about the resource tags used to identify resources that are retained by the retention rule.
The tag key.
The tag value.
dict
Response Syntax
{
'Identifier': 'string',
'RetentionPeriod': {
'RetentionPeriodValue': 123,
'RetentionPeriodUnit': 'DAYS'
},
'Description': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
],
'ResourceType': 'EBS_SNAPSHOT'|'EC2_IMAGE',
'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 the 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) --
Information about the tags assigned to the retention rule.
(dict) --
Information about the tags to assign to the 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 the resource tags used to identify resources that are retained by the 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 resources.
Exceptions
RecycleBin.Client.exceptions.ValidationException
RecycleBin.Client.exceptions.ServiceQuotaExceededException
RecycleBin.Client.exceptions.InternalServerException
delete_rule
(**kwargs)¶Deletes a Recycle Bin retention rule. For more information, see Delete Recycle Bin retention rules in the Amazon Elastic Compute Cloud User Guide .
See also: AWS API Documentation
Request Syntax
response = client.delete_rule(
Identifier='string'
)
[REQUIRED]
The unique ID of the retention rule.
{}
Response Structure
Exceptions
RecycleBin.Client.exceptions.InternalServerException
RecycleBin.Client.exceptions.ResourceNotFoundException
RecycleBin.Client.exceptions.ValidationException
get_paginator
(operation_name)¶Create a paginator for an operation.
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")
.client.can_paginate
method to
check if an operation is pageable.get_rule
(**kwargs)¶Gets information about a Recycle Bin retention rule.
See also: AWS API Documentation
Request Syntax
response = client.get_rule(
Identifier='string'
)
[REQUIRED]
The unique ID of the retention rule.
{
'Identifier': 'string',
'Description': 'string',
'ResourceType': 'EBS_SNAPSHOT'|'EC2_IMAGE',
'RetentionPeriod': {
'RetentionPeriodValue': 123,
'RetentionPeriodUnit': 'DAYS'
},
'ResourceTags': [
{
'ResourceTagKey': 'string',
'ResourceTagValue': 'string'
},
],
'Status': 'pending'|'available'
}
Response Structure
The unique ID of the retention rule.
The retention rule description.
The resource type retained by the retention rule.
Information about the retention period for which the retention rule is to retain resources.
The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .
The unit of time in which the retention period is measured. Currently, only DAYS
is supported.
Information about the resource tags used to identify resources that are retained by the retention rule.
Information about the resource tags used to identify resources that are retained by the retention rule.
The tag key.
The tag value.
The state of the retention rule. Only retention rules that are in the available
state retain resources.
Exceptions
RecycleBin.Client.exceptions.ValidationException
RecycleBin.Client.exceptions.InternalServerException
RecycleBin.Client.exceptions.ResourceNotFoundException
get_waiter
(waiter_name)¶Returns an object that can wait for some condition.
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'|'EC2_IMAGE',
ResourceTags=[
{
'ResourceTagKey': 'string',
'ResourceTagValue': 'string'
},
]
)
NextToken
value.[REQUIRED]
The resource type retained by the retention rule. Only retention rules that retain the specified resource type are listed. Currently, only Amazon EBS snapshots and EBS-backed AMIs are supported. To list retention rules that retain snapshots, specify EBS_SNAPSHOT
. To list retention rules that retain EBS-backed AMIs, specify EC2_IMAGE
.
Information about the resource tags used to identify resources that are retained by the retention rule.
Information about the resource tags used to identify resources that are retained by the retention rule.
The tag key.
The tag value.
dict
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 retention rule description.
RetentionPeriod (dict) --
Information about the retention period for which the 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.
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
RecycleBin.Client.exceptions.ValidationException
RecycleBin.Client.exceptions.InternalServerException
Lists the tags assigned to a retention rule.
See also: AWS API Documentation
Request Syntax
response = client.list_tags_for_resource(
ResourceArn='string'
)
[REQUIRED]
The Amazon Resource Name (ARN) of the retention rule.
{
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
}
Response Structure
Information about the tags assigned to the retention rule.
Information about the tags to assign to the retention rule.
The tag key.
The tag value.
Exceptions
RecycleBin.Client.exceptions.ValidationException
RecycleBin.Client.exceptions.InternalServerException
RecycleBin.Client.exceptions.ResourceNotFoundException
tag_resource
(**kwargs)¶Assigns tags to the specified retention rule.
See also: AWS API Documentation
Request Syntax
response = client.tag_resource(
ResourceArn='string',
Tags=[
{
'Key': 'string',
'Value': 'string'
},
]
)
[REQUIRED]
The Amazon Resource Name (ARN) of the retention rule.
[REQUIRED]
Information about the tags to assign to the retention rule.
Information about the tags to assign to the retention rule.
The tag key.
The tag value.
dict
Response Syntax
{}
Response Structure
Exceptions
RecycleBin.Client.exceptions.ValidationException
RecycleBin.Client.exceptions.InternalServerException
RecycleBin.Client.exceptions.ResourceNotFoundException
RecycleBin.Client.exceptions.ServiceQuotaExceededException
untag_resource
(**kwargs)¶Unassigns a tag from a retention rule.
See also: AWS API Documentation
Request Syntax
response = client.untag_resource(
ResourceArn='string',
TagKeys=[
'string',
]
)
[REQUIRED]
The Amazon Resource Name (ARN) of the retention rule.
[REQUIRED]
The tag keys of the tags to unassign. All tags that have the specified tag key are unassigned.
dict
Response Syntax
{}
Response Structure
Exceptions
RecycleBin.Client.exceptions.ValidationException
RecycleBin.Client.exceptions.InternalServerException
RecycleBin.Client.exceptions.ResourceNotFoundException
update_rule
(**kwargs)¶Updates an existing Recycle Bin retention rule. For more information, see Update Recycle Bin retention rules in the Amazon Elastic Compute Cloud 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'|'EC2_IMAGE',
ResourceTags=[
{
'ResourceTagKey': 'string',
'ResourceTagValue': 'string'
},
]
)
[REQUIRED]
The unique ID of the retention rule.
Information about the retention period for which the retention rule is to retain resources.
The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit .
The unit of time in which the retention period is measured. Currently, only DAYS
is supported.
EBS_SNAPSHOT
. To retain EBS-backed AMIs, specify EC2_IMAGE
.Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource 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.
To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.
Information about the resource tags used to identify resources that are retained by the retention rule.
The tag key.
The tag value.
dict
Response Syntax
{
'Identifier': 'string',
'RetentionPeriod': {
'RetentionPeriodValue': 123,
'RetentionPeriodUnit': 'DAYS'
},
'Description': 'string',
'ResourceType': 'EBS_SNAPSHOT'|'EC2_IMAGE',
'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 the 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 the resource tags used to identify resources that are retained by the 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 resources.
Exceptions
RecycleBin.Client.exceptions.ValidationException
RecycleBin.Client.exceptions.InternalServerException
RecycleBin.Client.exceptions.ResourceNotFoundException
The available paginators are:
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'|'EC2_IMAGE',
ResourceTags=[
{
'ResourceTagKey': 'string',
'ResourceTagValue': 'string'
},
],
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
[REQUIRED]
The resource type retained by the retention rule. Only retention rules that retain the specified resource type are listed. Currently, only Amazon EBS snapshots and EBS-backed AMIs are supported. To list retention rules that retain snapshots, specify EBS_SNAPSHOT
. To list retention rules that retain EBS-backed AMIs, specify EC2_IMAGE
.
Information about the resource tags used to identify resources that are retained by the retention rule.
Information about the resource tags used to identify resources that are retained by the retention rule.
The tag key.
The tag value.
A dictionary that provides parameters to control pagination.
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.
The size of each page.
A token to specify where to start paginating. This is the NextToken
from a previous response.
dict
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 retention rule description.
RetentionPeriod (dict) --
Information about the retention period for which the 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.