You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.
Class: Aws::DocDB::Client
- Inherits:
-
Seahorse::Client::Base
- Object
- Seahorse::Client::Base
- Aws::DocDB::Client
- Defined in:
- (unknown)
Overview
An API client for Amazon DocumentDB with MongoDB compatibility. To construct a client, you need to configure a :region
and :credentials
.
docdb = Aws::DocDB::Client.new(
region: region_name,
credentials: credentials,
# ...
)
See #initialize for a full list of supported configuration options.
Region
You can configure a default region in the following locations:
ENV['AWS_REGION']
Aws.config[:region]
Go here for a list of supported regions.
Credentials
Default credentials are loaded automatically from the following locations:
ENV['AWS_ACCESS_KEY_ID']
andENV['AWS_SECRET_ACCESS_KEY']
Aws.config[:credentials]
- The shared credentials ini file at
~/.aws/credentials
(more information) - From an instance profile when running on EC2
You can also construct a credentials object from one of the following classes:
Alternatively, you configure credentials with :access_key_id
and
:secret_access_key
:
# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))
Aws::DocDB::Client.new(
access_key_id: creds['access_key_id'],
secret_access_key: creds['secret_access_key']
)
Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.
Instance Attribute Summary
Attributes inherited from Seahorse::Client::Base
Constructor collapse
-
#initialize(options = {}) ⇒ Aws::DocDB::Client
constructor
Constructs an API client.
API Operations collapse
-
#add_tags_to_resource(options = {}) ⇒ Struct
Adds metadata tags to an Amazon DocumentDB resource.
-
#apply_pending_maintenance_action(options = {}) ⇒ Types::ApplyPendingMaintenanceActionResult
Applies a pending maintenance action to a resource (for example, to an Amazon DocumentDB instance).
.
-
#copy_db_cluster_parameter_group(options = {}) ⇒ Types::CopyDBClusterParameterGroupResult
Copies the specified cluster parameter group.
.
-
#copy_db_cluster_snapshot(options = {}) ⇒ Types::CopyDBClusterSnapshotResult
Copies a snapshot of a cluster.
To copy a cluster snapshot from a shared manual cluster snapshot,
SourceDBClusterSnapshotIdentifier
must be the Amazon Resource Name (ARN) of the shared cluster snapshot. -
#create_db_cluster(options = {}) ⇒ Types::CreateDBClusterResult
Creates a new Amazon DocumentDB cluster.
.
-
#create_db_cluster_parameter_group(options = {}) ⇒ Types::CreateDBClusterParameterGroupResult
Creates a new cluster parameter group.
Parameters in a cluster parameter group apply to all of the instances in a cluster.
A cluster parameter group is initially created with the default parameters for the database engine used by instances in the cluster.
-
#create_db_cluster_snapshot(options = {}) ⇒ Types::CreateDBClusterSnapshotResult
Creates a snapshot of a cluster.
-
#create_db_instance(options = {}) ⇒ Types::CreateDBInstanceResult
Creates a new instance.
.
-
#create_db_subnet_group(options = {}) ⇒ Types::CreateDBSubnetGroupResult
Creates a new subnet group.
-
#delete_db_cluster(options = {}) ⇒ Types::DeleteDBClusterResult
Deletes a previously provisioned cluster.
-
#delete_db_cluster_parameter_group(options = {}) ⇒ Struct
Deletes a specified cluster parameter group.
-
#delete_db_cluster_snapshot(options = {}) ⇒ Types::DeleteDBClusterSnapshotResult
Deletes a cluster snapshot.
-
#delete_db_instance(options = {}) ⇒ Types::DeleteDBInstanceResult
Deletes a previously provisioned instance.
-
#delete_db_subnet_group(options = {}) ⇒ Struct
Deletes a subnet group.
The specified database subnet group must not be associated with any DB instances.
-
#describe_certificates(options = {}) ⇒ Types::CertificateMessage
Returns a list of certificate authority (CA) certificates provided by Amazon DocumentDB for this AWS account.
.
-
#describe_db_cluster_parameter_groups(options = {}) ⇒ Types::DBClusterParameterGroupsMessage
Returns a list of
DBClusterParameterGroup
descriptions. -
#describe_db_cluster_parameters(options = {}) ⇒ Types::DBClusterParameterGroupDetails
Returns the detailed parameter list for a particular cluster parameter group.
.
-
#describe_db_cluster_snapshot_attributes(options = {}) ⇒ Types::DescribeDBClusterSnapshotAttributesResult
Returns a list of cluster snapshot attribute names and values for a manual DB cluster snapshot.
When you share snapshots with other AWS accounts,
DescribeDBClusterSnapshotAttributes
returns therestore
attribute and a list of IDs for the AWS accounts that are authorized to copy or restore the manual cluster snapshot. -
#describe_db_cluster_snapshots(options = {}) ⇒ Types::DBClusterSnapshotMessage
Returns information about cluster snapshots.
-
#describe_db_clusters(options = {}) ⇒ Types::DBClusterMessage
Returns information about provisioned Amazon DocumentDB clusters.
-
#describe_db_engine_versions(options = {}) ⇒ Types::DBEngineVersionMessage
Returns a list of the available engines.
.
-
#describe_db_instances(options = {}) ⇒ Types::DBInstanceMessage
Returns information about provisioned Amazon DocumentDB instances.
-
#describe_db_subnet_groups(options = {}) ⇒ Types::DBSubnetGroupMessage
Returns a list of
DBSubnetGroup
descriptions. -
#describe_engine_default_cluster_parameters(options = {}) ⇒ Types::DescribeEngineDefaultClusterParametersResult
Returns the default engine and system parameter information for the cluster database engine.
.
-
#describe_event_categories(options = {}) ⇒ Types::EventCategoriesMessage
Displays a list of categories for all event source types, or, if specified, for a specified source type.
-
#describe_events(options = {}) ⇒ Types::EventsMessage
Returns events related to instances, security groups, snapshots, and DB parameter groups for the past 14 days.
-
#describe_orderable_db_instance_options(options = {}) ⇒ Types::OrderableDBInstanceOptionsMessage
Returns a list of orderable instance options for the specified engine.
.
-
#describe_pending_maintenance_actions(options = {}) ⇒ Types::PendingMaintenanceActionsMessage
Returns a list of resources (for example, instances) that have at least one pending maintenance action.
.
-
#failover_db_cluster(options = {}) ⇒ Types::FailoverDBClusterResult
Forces a failover for a cluster.
A failover for a cluster promotes one of the Amazon DocumentDB replicas (read-only instances) in the cluster to be the primary instance (the cluster writer).
If the primary instance fails, Amazon DocumentDB automatically fails over to an Amazon DocumentDB replica, if one exists.
-
#list_tags_for_resource(options = {}) ⇒ Types::TagListMessage
Lists all tags on an Amazon DocumentDB resource.
.
-
#modify_db_cluster(options = {}) ⇒ Types::ModifyDBClusterResult
Modifies a setting for an Amazon DocumentDB cluster.
-
#modify_db_cluster_parameter_group(options = {}) ⇒ Types::DBClusterParameterGroupNameMessage
Modifies the parameters of a cluster parameter group.
-
#modify_db_cluster_snapshot_attribute(options = {}) ⇒ Types::ModifyDBClusterSnapshotAttributeResult
Adds an attribute and values to, or removes an attribute and values from, a manual DB cluster snapshot.
To share a manual cluster snapshot with other AWS accounts, specify
restore
as theAttributeName
, and use theValuesToAdd
parameter to add a list of IDs of the AWS accounts that are authorized to restore the manual cluster snapshot. -
#modify_db_instance(options = {}) ⇒ Types::ModifyDBInstanceResult
Modifies settings for an instance.
-
#modify_db_subnet_group(options = {}) ⇒ Types::ModifyDBSubnetGroupResult
Modifies an existing subnet group.
-
#reboot_db_instance(options = {}) ⇒ Types::RebootDBInstanceResult
You might need to reboot your instance, usually for maintenance reasons.
-
#remove_tags_from_resource(options = {}) ⇒ Struct
Removes metadata tags from an Amazon DocumentDB resource.
.
-
#reset_db_cluster_parameter_group(options = {}) ⇒ Types::DBClusterParameterGroupNameMessage
Modifies the parameters of a cluster parameter group to the default value.
-
#restore_db_cluster_from_snapshot(options = {}) ⇒ Types::RestoreDBClusterFromSnapshotResult
Creates a new cluster from a snapshot or cluster snapshot.
If a snapshot is specified, the target cluster is created from the source DB snapshot with a default configuration and default security group.
If a cluster snapshot is specified, the target cluster is created from the source cluster restore point with the same configuration as the original source DB cluster, except that the new cluster is created with the default security group.
. -
#restore_db_cluster_to_point_in_time(options = {}) ⇒ Types::RestoreDBClusterToPointInTimeResult
Restores a cluster to an arbitrary point in time.
-
#start_db_cluster(options = {}) ⇒ Types::StartDBClusterResult
Restarts the stopped cluster that is specified by
DBClusterIdentifier
. -
#stop_db_cluster(options = {}) ⇒ Types::StopDBClusterResult
Stops the running cluster that is specified by
DBClusterIdentifier
.
Instance Method Summary collapse
-
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
-
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters.
Methods inherited from Seahorse::Client::Base
add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response
Constructor Details
#initialize(options = {}) ⇒ Aws::DocDB::Client
Constructs an API client.
Instance Method Details
#add_tags_to_resource(options = {}) ⇒ Struct
Adds metadata tags to an Amazon DocumentDB resource. You can use these tags with cost allocation reporting to track costs that are associated with Amazon DocumentDB resources. or in a Condition
statement in an AWS Identity and Access Management (IAM) policy for Amazon DocumentDB.
#apply_pending_maintenance_action(options = {}) ⇒ Types::ApplyPendingMaintenanceActionResult
Applies a pending maintenance action to a resource (for example, to an Amazon DocumentDB instance).
#copy_db_cluster_parameter_group(options = {}) ⇒ Types::CopyDBClusterParameterGroupResult
Copies the specified cluster parameter group.
#copy_db_cluster_snapshot(options = {}) ⇒ Types::CopyDBClusterSnapshotResult
Copies a snapshot of a cluster.
To copy a cluster snapshot from a shared manual cluster snapshot, SourceDBClusterSnapshotIdentifier
must be the Amazon Resource Name (ARN) of the shared cluster snapshot. You can only copy a shared DB cluster snapshot, whether encrypted or not, in the same AWS Region.
To cancel the copy operation after it is in progress, delete the target cluster snapshot identified by TargetDBClusterSnapshotIdentifier
while that cluster snapshot is in the copying status.
#create_db_cluster(options = {}) ⇒ Types::CreateDBClusterResult
Creates a new Amazon DocumentDB cluster.
#create_db_cluster_parameter_group(options = {}) ⇒ Types::CreateDBClusterParameterGroupResult
Creates a new cluster parameter group.
Parameters in a cluster parameter group apply to all of the instances in a cluster.
A cluster parameter group is initially created with the default parameters for the database engine used by instances in the cluster. In Amazon DocumentDB, you cannot make modifications directly to the default.docdb3.6
cluster parameter group. If your Amazon DocumentDB cluster is using the default cluster parameter group and you want to modify a value in it, you must first create a new parameter group or copy an existing parameter group, modify it, and then apply the modified parameter group to your cluster. For the new cluster parameter group and associated settings to take effect, you must then reboot the instances in the cluster without failover. For more information, see Modifying Amazon DocumentDB Cluster Parameter Groups.
#create_db_cluster_snapshot(options = {}) ⇒ Types::CreateDBClusterSnapshotResult
Creates a snapshot of a cluster.
#create_db_instance(options = {}) ⇒ Types::CreateDBInstanceResult
Creates a new instance.
#create_db_subnet_group(options = {}) ⇒ Types::CreateDBSubnetGroupResult
Creates a new subnet group. subnet groups must contain at least one subnet in at least two Availability Zones in the AWS Region.
#delete_db_cluster(options = {}) ⇒ Types::DeleteDBClusterResult
Deletes a previously provisioned cluster. When you delete a cluster, all automated backups for that cluster are deleted and can't be recovered. Manual DB cluster snapshots of the specified cluster are not deleted.
#delete_db_cluster_parameter_group(options = {}) ⇒ Struct
Deletes a specified cluster parameter group. The cluster parameter group to be deleted can't be associated with any clusters.
#delete_db_cluster_snapshot(options = {}) ⇒ Types::DeleteDBClusterSnapshotResult
Deletes a cluster snapshot. If the snapshot is being copied, the copy operation is terminated.
The cluster snapshot must be in the available
state to be deleted.
#delete_db_instance(options = {}) ⇒ Types::DeleteDBInstanceResult
Deletes a previously provisioned instance.
#delete_db_subnet_group(options = {}) ⇒ Struct
Deletes a subnet group.
The specified database subnet group must not be associated with any DB instances.
#describe_certificates(options = {}) ⇒ Types::CertificateMessage
Returns a list of certificate authority (CA) certificates provided by Amazon DocumentDB for this AWS account.
#describe_db_cluster_parameter_groups(options = {}) ⇒ Types::DBClusterParameterGroupsMessage
Returns a list of DBClusterParameterGroup
descriptions. If a DBClusterParameterGroupName
parameter is specified, the list contains only the description of the specified cluster parameter group.
#describe_db_cluster_parameters(options = {}) ⇒ Types::DBClusterParameterGroupDetails
Returns the detailed parameter list for a particular cluster parameter group.
#describe_db_cluster_snapshot_attributes(options = {}) ⇒ Types::DescribeDBClusterSnapshotAttributesResult
Returns a list of cluster snapshot attribute names and values for a manual DB cluster snapshot.
When you share snapshots with other AWS accounts, DescribeDBClusterSnapshotAttributes
returns the restore
attribute and a list of IDs for the AWS accounts that are authorized to copy or restore the manual cluster snapshot. If all
is included in the list of values for the restore
attribute, then the manual cluster snapshot is public and can be copied or restored by all AWS accounts.
#describe_db_cluster_snapshots(options = {}) ⇒ Types::DBClusterSnapshotMessage
Returns information about cluster snapshots. This API operation supports pagination.
#describe_db_clusters(options = {}) ⇒ Types::DBClusterMessage
Returns information about provisioned Amazon DocumentDB clusters. This API operation supports pagination. For certain management features such as cluster and instance lifecycle management, Amazon DocumentDB leverages operational technology that is shared with Amazon RDS and Amazon Neptune. Use the filterName=engine,Values=docdb
filter parameter to return only Amazon DocumentDB clusters.
#describe_db_engine_versions(options = {}) ⇒ Types::DBEngineVersionMessage
Returns a list of the available engines.
#describe_db_instances(options = {}) ⇒ Types::DBInstanceMessage
Returns information about provisioned Amazon DocumentDB instances. This API supports pagination.
#describe_db_subnet_groups(options = {}) ⇒ Types::DBSubnetGroupMessage
Returns a list of DBSubnetGroup
descriptions. If a DBSubnetGroupName
is specified, the list will contain only the descriptions of the specified DBSubnetGroup
.
#describe_engine_default_cluster_parameters(options = {}) ⇒ Types::DescribeEngineDefaultClusterParametersResult
Returns the default engine and system parameter information for the cluster database engine.
#describe_event_categories(options = {}) ⇒ Types::EventCategoriesMessage
Displays a list of categories for all event source types, or, if specified, for a specified source type.
#describe_events(options = {}) ⇒ Types::EventsMessage
Returns events related to instances, security groups, snapshots, and DB parameter groups for the past 14 days. You can obtain events specific to a particular DB instance, security group, snapshot, or parameter group by providing the name as a parameter. By default, the events of the past hour are returned.
#describe_orderable_db_instance_options(options = {}) ⇒ Types::OrderableDBInstanceOptionsMessage
Returns a list of orderable instance options for the specified engine.
#describe_pending_maintenance_actions(options = {}) ⇒ Types::PendingMaintenanceActionsMessage
Returns a list of resources (for example, instances) that have at least one pending maintenance action.
#failover_db_cluster(options = {}) ⇒ Types::FailoverDBClusterResult
Forces a failover for a cluster.
A failover for a cluster promotes one of the Amazon DocumentDB replicas (read-only instances) in the cluster to be the primary instance (the cluster writer).
If the primary instance fails, Amazon DocumentDB automatically fails over to an Amazon DocumentDB replica, if one exists. You can force a failover when you want to simulate a failure of a primary instance for testing.
#list_tags_for_resource(options = {}) ⇒ Types::TagListMessage
Lists all tags on an Amazon DocumentDB resource.
#modify_db_cluster(options = {}) ⇒ Types::ModifyDBClusterResult
Modifies a setting for an Amazon DocumentDB cluster. You can change one or more database configuration parameters by specifying these parameters and the new values in the request.
#modify_db_cluster_parameter_group(options = {}) ⇒ Types::DBClusterParameterGroupNameMessage
Modifies the parameters of a cluster parameter group. To modify more than one parameter, submit a list of the following: ParameterName
, ParameterValue
, and ApplyMethod
. A maximum of 20 parameters can be modified in a single request.
Changes to dynamic parameters are applied immediately. Changes to static parameters require a reboot or maintenance window before the change can take effect. After you create a cluster parameter group, you should wait at least 5 minutes before creating your first cluster that uses that cluster parameter group as the default parameter group. This allows Amazon DocumentDB to fully complete the create action before the parameter group is used as the default for a new cluster. This step is especially important for parameters that are critical when creating the default database for a cluster, such as the character set for the default database defined by the character_set_database
parameter.
#modify_db_cluster_snapshot_attribute(options = {}) ⇒ Types::ModifyDBClusterSnapshotAttributeResult
Adds an attribute and values to, or removes an attribute and values from, a manual DB cluster snapshot.
To share a manual cluster snapshot with other AWS accounts, specify restore
as the AttributeName
, and use the ValuesToAdd
parameter to add a list of IDs of the AWS accounts that are authorized to restore the manual cluster snapshot. Use the value all
to make the manual cluster snapshot public, which means that it can be copied or restored by all AWS accounts. Do not add the all
value for any manual DB cluster snapshots that contain private information that you don't want available to all AWS accounts. If a manual cluster snapshot is encrypted, it can be shared, but only by specifying a list of authorized AWS account IDs for the ValuesToAdd
parameter. You can't use all
as a value for that parameter in this case.
#modify_db_instance(options = {}) ⇒ Types::ModifyDBInstanceResult
Modifies settings for an instance. You can change one or more database configuration parameters by specifying these parameters and the new values in the request.
#modify_db_subnet_group(options = {}) ⇒ Types::ModifyDBSubnetGroupResult
Modifies an existing subnet group. subnet groups must contain at least one subnet in at least two Availability Zones in the AWS Region.
#reboot_db_instance(options = {}) ⇒ Types::RebootDBInstanceResult
You might need to reboot your instance, usually for maintenance reasons. For example, if you make certain changes, or if you change the cluster parameter group that is associated with the instance, you must reboot the instance for the changes to take effect.
Rebooting an instance restarts the database engine service. Rebooting an instance results in a momentary outage, during which the instance status is set to rebooting.
#remove_tags_from_resource(options = {}) ⇒ Struct
Removes metadata tags from an Amazon DocumentDB resource.
#reset_db_cluster_parameter_group(options = {}) ⇒ Types::DBClusterParameterGroupNameMessage
Modifies the parameters of a cluster parameter group to the default value. To reset specific parameters, submit a list of the following: ParameterName
and ApplyMethod
. To reset the entire cluster parameter group, specify the DBClusterParameterGroupName
and ResetAllParameters
parameters.
When you reset the entire group, dynamic parameters are updated immediately and static parameters are set to pending-reboot
to take effect on the next DB instance reboot.
#restore_db_cluster_from_snapshot(options = {}) ⇒ Types::RestoreDBClusterFromSnapshotResult
Creates a new cluster from a snapshot or cluster snapshot.
If a snapshot is specified, the target cluster is created from the source DB snapshot with a default configuration and default security group.
If a cluster snapshot is specified, the target cluster is created from the source cluster restore point with the same configuration as the original source DB cluster, except that the new cluster is created with the default security group.
#restore_db_cluster_to_point_in_time(options = {}) ⇒ Types::RestoreDBClusterToPointInTimeResult
Restores a cluster to an arbitrary point in time. Users can restore to any point in time before LatestRestorableTime
for up to BackupRetentionPeriod
days. The target cluster is created from the source cluster with the same configuration as the original cluster, except that the new cluster is created with the default security group.
#start_db_cluster(options = {}) ⇒ Types::StartDBClusterResult
Restarts the stopped cluster that is specified by DBClusterIdentifier
. For more information, see Stopping and Starting an Amazon DocumentDB Cluster.
#stop_db_cluster(options = {}) ⇒ Types::StopDBClusterResult
Stops the running cluster that is specified by DBClusterIdentifier
. The cluster must be in the available state. For more information, see Stopping and Starting an Amazon DocumentDB Cluster.
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean
Waiters polls an API operation until a resource enters a desired state.
Basic Usage
Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)
Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:
# poll for ~25 seconds
client.wait_until(...) do |w|
w.max_attempts = 5
w.delay = 5
end
Callbacks
You can be notified before each polling attempt and before each
delay. If you throw :success
or :failure
from these callbacks,
it will terminate the waiter.
started_at = Time.now
client.wait_until(...) do |w|
# disable max attempts
w.max_attempts = nil
# poll for 1 hour, instead of a number of attempts
w.before_wait do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
end
Handling Errors
When a waiter is successful, it returns true
. When a waiter
fails, it raises an error. All errors raised extend from
Waiters::Errors::WaiterFailed.
begin
client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:
Waiter Name | Client Method | Default Delay: | Default Max Attempts: |
---|---|---|---|
:db_instance_available | #describe_db_instances | 30 | 60 |
:db_instance_deleted | #describe_db_instances | 30 | 60 |