You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::RDSDataService::Client

Inherits:
Seahorse::Client::Base show all
Defined in:
(unknown)

Overview

An API client for AWS RDS DataService. To construct a client, you need to configure a :region and :credentials.

rdsdataservice = Aws::RDSDataService::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'] and ENV['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::RDSDataService::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

#config, #handlers

Constructor collapse

API Operations collapse

Instance Method Summary collapse

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::RDSDataService::Client

Constructs an API client.

Options Hash (options):

  • :access_key_id (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :active_endpoint_cache (Boolean)

    When set to true, a thread polling for endpoints will be running in the background every 60 secs (default). Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :convert_params (Boolean) — default: true

    When true, an attempt is made to coerce request parameters into the required types. See Plugins::ParamConverter for more details.

  • :credentials (required, Credentials)

    Your AWS credentials. The following locations will be searched in order for credentials:

    • :access_key_id, :secret_access_key, and :session_token options
    • ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
    • HOME/.aws/credentials shared credentials file
    • EC2 instance profile credentials See Plugins::RequestSigner for more details.
  • :disable_host_prefix_injection (Boolean)

    Set to true to disable SDK automatically adding host prefix to default service endpoint when available. See Plugins::EndpointPattern for more details.

  • :endpoint (String)

    A default endpoint is constructed from the :region. See Plugins::RegionalEndpoint for more details.

  • :endpoint_cache_max_entries (Integer)

    Used for the maximum size limit of the LRU cache storing endpoints data for endpoint discovery enabled operations. Defaults to 1000. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_max_threads (Integer)

    Used for the maximum threads in use for polling endpoints to be cached, defaults to 10. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_poll_interval (Integer)

    When :endpoint_discovery and :active_endpoint_cache is enabled, Use this option to config the time interval in seconds for making requests fetching endpoints information. Defaults to 60 sec. See Plugins::EndpointDiscovery for more details.

  • :endpoint_discovery (Boolean)

    When set to true, endpoint discovery will be enabled for operations when available. Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :http_continue_timeout (Float) — default: 1

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_idle_timeout (Integer) — default: 5

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_open_timeout (Integer) — default: 15

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_proxy (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_read_timeout (Integer) — default: 60

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_wire_trace (Boolean) — default: false

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the logger at. See Plugins::Logging for more details.

  • :log_formatter (Logging::LogFormatter)

    The log formatter. Defaults to Seahorse::Client::Logging::Formatter.default. See Plugins::Logging for more details.

  • :logger (Logger) — default: nil

    The Logger instance to send log messages to. If this option is not set, logging will be disabled. See Plugins::Logging for more details.

  • :profile (String)

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, 'default' is used. See Plugins::RequestSigner for more details.

  • :raise_response_errors (Boolean) — default: true

    When true, response errors are raised. See Seahorse::Client::Plugins::RaiseResponseErrors for more details.

  • :region (required, String)

    The AWS region to connect to. The region is used to construct the client endpoint. Defaults to ENV['AWS_REGION']. Also checks AMAZON_REGION and AWS_DEFAULT_REGION. See Plugins::RegionalEndpoint for more details.

  • :retry_limit (Integer) — default: 3

    The maximum number of times to retry failed requests. Only ~ 500 level server errors and certain ~ 400 level client errors are retried. Generally, these are throttling errors, data checksum errors, networking errors, timeout errors and auth errors from expired credentials. See Plugins::RetryErrors for more details.

  • :secret_access_key (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :session_token (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :ssl_ca_bundle (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_directory (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_store (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_verify_peer (Boolean) — default: true

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :stub_responses (Boolean) — default: false

    Causes the client to return stubbed responses. By default fake responses are generated and returned. You can specify the response data to return or errors to raise by calling ClientStubs#stub_responses. See ClientStubs for more information.

    Please note When response stubbing is enabled, no HTTP requests are made, and retries are disabled. See Plugins::StubResponses for more details.

  • :validate_params (Boolean) — default: true

    When true, request parameters are validated before sending the request. See Plugins::ParamValidator for more details.

Instance Method Details

#batch_execute_statement(options = {}) ⇒ Types::BatchExecuteStatementResponse

Runs a batch SQL statement over an array of data.

You can run bulk update and insert operations for multiple records using a DML statement with different parameter sets. Bulk operations can provide a significant performance improvement over individual insert and update operations.

If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.

Examples:

Request syntax with placeholder values


resp = client.batch_execute_statement({
  database: "DbName",
  parameter_sets: [
    [
      {
        name: "ParameterName",
        type_hint: "DATE", # accepts DATE, DECIMAL, TIME, TIMESTAMP
        value: {
          array_value: {
            array_values: [
              {
                # recursive ArrayValue
              },
            ],
            boolean_values: [false],
            double_values: [1.0],
            long_values: [1],
            string_values: ["String"],
          },
          blob_value: "data",
          boolean_value: false,
          double_value: 1.0,
          is_null: false,
          long_value: 1,
          string_value: "String",
        },
      },
    ],
  ],
  resource_arn: "Arn", # required
  schema: "DbName",
  secret_arn: "Arn", # required
  sql: "SqlStatement", # required
  transaction_id: "Id",
})

Response structure


resp.update_results #=> Array
resp.update_results[0].generated_fields #=> Array
resp.update_results[0].generated_fields[0].array_value.array_values #=> Array
resp.update_results[0].generated_fields[0].array_value.array_values[0] #=> Types::ArrayValue
resp.update_results[0].generated_fields[0].array_value.boolean_values #=> Array
resp.update_results[0].generated_fields[0].array_value.boolean_values[0] #=> true/false
resp.update_results[0].generated_fields[0].array_value.double_values #=> Array
resp.update_results[0].generated_fields[0].array_value.double_values[0] #=> Float
resp.update_results[0].generated_fields[0].array_value.long_values #=> Array
resp.update_results[0].generated_fields[0].array_value.long_values[0] #=> Integer
resp.update_results[0].generated_fields[0].array_value.string_values #=> Array
resp.update_results[0].generated_fields[0].array_value.string_values[0] #=> String
resp.update_results[0].generated_fields[0].blob_value #=> IO
resp.update_results[0].generated_fields[0].boolean_value #=> true/false
resp.update_results[0].generated_fields[0].double_value #=> Float
resp.update_results[0].generated_fields[0].is_null #=> true/false
resp.update_results[0].generated_fields[0].long_value #=> Integer
resp.update_results[0].generated_fields[0].string_value #=> String

Options Hash (options):

  • :database (String)

    The name of the database.

  • :parameter_sets (Array<Array<Types::SqlParameter>>)

    The parameter set for the batch operation.

    The SQL statement is executed as many times as the number of parameter sets provided. To execute a SQL statement with no parameters, use one of the following options:

    • Specify one or more empty parameter sets.

    • Use the ExecuteStatement operation instead of the BatchExecuteStatement operation.

    Array parameters are not supported.

  • :resource_arn (required, String)

    The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

  • :schema (String)

    The name of the database schema.

  • :secret_arn (required, String)

    The name or ARN of the secret that enables access to the DB cluster.

  • :sql (required, String)

    The SQL statement to run.

  • :transaction_id (String)

    The identifier of a transaction that was started by using the BeginTransaction operation. Specify the transaction ID of the transaction that you want to include the SQL statement in.

    If the SQL statement is not part of a transaction, don\'t set this parameter.

Returns:

See Also:

#begin_transaction(options = {}) ⇒ Types::BeginTransactionResponse

Starts a SQL transaction.

 <important> <p>A transaction can run for a maximum of 24 hours. A transaction is terminated and rolled back automatically after 24 hours.</p> <p>A transaction times out if no calls use its transaction ID in three minutes. If a transaction times out before it's committed, it's rolled back automatically.</p> <p>DDL statements inside a transaction cause an implicit commit. We recommend that you run each DDL statement in a separate <code>ExecuteStatement</code> call with <code>continueAfterTimeout</code> enabled.</p> </important> 

Examples:

Request syntax with placeholder values


resp = client.begin_transaction({
  database: "DbName",
  resource_arn: "Arn", # required
  schema: "DbName",
  secret_arn: "Arn", # required
})

Response structure


resp.transaction_id #=> String

Options Hash (options):

  • :database (String)

    The name of the database.

  • :resource_arn (required, String)

    The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

  • :schema (String)

    The name of the database schema.

  • :secret_arn (required, String)

    The name or ARN of the secret that enables access to the DB cluster.

Returns:

See Also:

#commit_transaction(options = {}) ⇒ Types::CommitTransactionResponse

Ends a SQL transaction started with the BeginTransaction operation and commits the changes.

Examples:

Request syntax with placeholder values


resp = client.commit_transaction({
  resource_arn: "Arn", # required
  secret_arn: "Arn", # required
  transaction_id: "Id", # required
})

Response structure


resp.transaction_status #=> String

Options Hash (options):

  • :resource_arn (required, String)

    The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

  • :secret_arn (required, String)

    The name or ARN of the secret that enables access to the DB cluster.

  • :transaction_id (required, String)

    The identifier of the transaction to end and commit.

Returns:

See Also:

#execute_sql(options = {}) ⇒ Types::ExecuteSqlResponse

Runs one or more SQL statements.

This operation is deprecated. Use the BatchExecuteStatement or ExecuteStatement operation.

Examples:

Request syntax with placeholder values


resp = client.execute_sql({
  aws_secret_store_arn: "Arn", # required
  database: "DbName",
  db_cluster_or_instance_arn: "Arn", # required
  schema: "DbName",
  sql_statements: "SqlStatement", # required
})

Response structure


resp.sql_statement_results #=> Array
resp.sql_statement_results[0].number_of_records_updated #=> Integer
resp.sql_statement_results[0].result_frame.records #=> Array
resp.sql_statement_results[0].result_frame.records[0].values #=> Array
resp.sql_statement_results[0].result_frame.records[0].values[0].array_values #=> Array
resp.sql_statement_results[0].result_frame.records[0].values[0].array_values[0] #=> Types::Value
resp.sql_statement_results[0].result_frame.records[0].values[0].big_int_value #=> Integer
resp.sql_statement_results[0].result_frame.records[0].values[0].bit_value #=> true/false
resp.sql_statement_results[0].result_frame.records[0].values[0].blob_value #=> IO
resp.sql_statement_results[0].result_frame.records[0].values[0].double_value #=> Float
resp.sql_statement_results[0].result_frame.records[0].values[0].int_value #=> Integer
resp.sql_statement_results[0].result_frame.records[0].values[0].is_null #=> true/false
resp.sql_statement_results[0].result_frame.records[0].values[0].real_value #=> Float
resp.sql_statement_results[0].result_frame.records[0].values[0].string_value #=> String
resp.sql_statement_results[0].result_frame.records[0].values[0].struct_value.attributes #=> Array
resp.sql_statement_results[0].result_frame.records[0].values[0].struct_value.attributes[0] #=> Types::Value
resp.sql_statement_results[0].result_frame..column_count #=> Integer
resp.sql_statement_results[0].result_frame.. #=> Array
resp.sql_statement_results[0].result_frame..[0].array_base_column_type #=> Integer
resp.sql_statement_results[0].result_frame..[0].is_auto_increment #=> true/false
resp.sql_statement_results[0].result_frame..[0].is_case_sensitive #=> true/false
resp.sql_statement_results[0].result_frame..[0].is_currency #=> true/false
resp.sql_statement_results[0].result_frame..[0].is_signed #=> true/false
resp.sql_statement_results[0].result_frame..[0].label #=> String
resp.sql_statement_results[0].result_frame..[0].name #=> String
resp.sql_statement_results[0].result_frame..[0].nullable #=> Integer
resp.sql_statement_results[0].result_frame..[0].precision #=> Integer
resp.sql_statement_results[0].result_frame..[0].scale #=> Integer
resp.sql_statement_results[0].result_frame..[0].schema_name #=> String
resp.sql_statement_results[0].result_frame..[0].table_name #=> String
resp.sql_statement_results[0].result_frame..[0].type #=> Integer
resp.sql_statement_results[0].result_frame..[0].type_name #=> String

Options Hash (options):

  • :aws_secret_store_arn (required, String)

    The Amazon Resource Name (ARN) of the secret that enables access to the DB cluster.

  • :database (String)

    The name of the database.

  • :db_cluster_or_instance_arn (required, String)

    The ARN of the Aurora Serverless DB cluster.

  • :schema (String)

    The name of the database schema.

  • :sql_statements (required, String)

    One or more SQL statements to run on the DB cluster.

    You can separate SQL statements from each other with a semicolon (;). Any valid SQL statement is permitted, including data definition, data manipulation, and commit statements.

Returns:

See Also:

#execute_statement(options = {}) ⇒ Types::ExecuteStatementResponse

Runs a SQL statement against a database.

If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.

The response size limit is 1 MB. If the call returns more than 1 MB of response data, the call is terminated.

Examples:

Request syntax with placeholder values


resp = client.execute_statement({
  continue_after_timeout: false,
  database: "DbName",
  include_result_metadata: false,
  parameters: [
    {
      name: "ParameterName",
      type_hint: "DATE", # accepts DATE, DECIMAL, TIME, TIMESTAMP
      value: {
        array_value: {
          array_values: [
            {
              # recursive ArrayValue
            },
          ],
          boolean_values: [false],
          double_values: [1.0],
          long_values: [1],
          string_values: ["String"],
        },
        blob_value: "data",
        boolean_value: false,
        double_value: 1.0,
        is_null: false,
        long_value: 1,
        string_value: "String",
      },
    },
  ],
  resource_arn: "Arn", # required
  result_set_options: {
    decimal_return_type: "DOUBLE_OR_LONG", # accepts DOUBLE_OR_LONG, STRING
  },
  schema: "DbName",
  secret_arn: "Arn", # required
  sql: "SqlStatement", # required
  transaction_id: "Id",
})

Response structure


resp. #=> Array
resp.[0].array_base_column_type #=> Integer
resp.[0].is_auto_increment #=> true/false
resp.[0].is_case_sensitive #=> true/false
resp.[0].is_currency #=> true/false
resp.[0].is_signed #=> true/false
resp.[0].label #=> String
resp.[0].name #=> String
resp.[0].nullable #=> Integer
resp.[0].precision #=> Integer
resp.[0].scale #=> Integer
resp.[0].schema_name #=> String
resp.[0].table_name #=> String
resp.[0].type #=> Integer
resp.[0].type_name #=> String
resp.generated_fields #=> Array
resp.generated_fields[0].array_value.array_values #=> Array
resp.generated_fields[0].array_value.array_values[0] #=> Types::ArrayValue
resp.generated_fields[0].array_value.boolean_values #=> Array
resp.generated_fields[0].array_value.boolean_values[0] #=> true/false
resp.generated_fields[0].array_value.double_values #=> Array
resp.generated_fields[0].array_value.double_values[0] #=> Float
resp.generated_fields[0].array_value.long_values #=> Array
resp.generated_fields[0].array_value.long_values[0] #=> Integer
resp.generated_fields[0].array_value.string_values #=> Array
resp.generated_fields[0].array_value.string_values[0] #=> String
resp.generated_fields[0].blob_value #=> IO
resp.generated_fields[0].boolean_value #=> true/false
resp.generated_fields[0].double_value #=> Float
resp.generated_fields[0].is_null #=> true/false
resp.generated_fields[0].long_value #=> Integer
resp.generated_fields[0].string_value #=> String
resp.number_of_records_updated #=> Integer
resp.records #=> Array
resp.records[0] #=> Array
resp.records[0][0].array_value.array_values #=> Array
resp.records[0][0].array_value.array_values[0] #=> Types::ArrayValue
resp.records[0][0].array_value.boolean_values #=> Array
resp.records[0][0].array_value.boolean_values[0] #=> true/false
resp.records[0][0].array_value.double_values #=> Array
resp.records[0][0].array_value.double_values[0] #=> Float
resp.records[0][0].array_value.long_values #=> Array
resp.records[0][0].array_value.long_values[0] #=> Integer
resp.records[0][0].array_value.string_values #=> Array
resp.records[0][0].array_value.string_values[0] #=> String
resp.records[0][0].blob_value #=> IO
resp.records[0][0].boolean_value #=> true/false
resp.records[0][0].double_value #=> Float
resp.records[0][0].is_null #=> true/false
resp.records[0][0].long_value #=> Integer
resp.records[0][0].string_value #=> String

Options Hash (options):

  • :continue_after_timeout (Boolean)

    A value that indicates whether to continue running the statement after the call times out. By default, the statement stops running when the call times out.

    For DDL statements, we recommend continuing to run the statement after the call times out. When a DDL statement terminates before it is finished running, it can result in errors and possibly corrupted data structures.

  • :database (String)

    The name of the database.

  • :include_result_metadata (Boolean)

    A value that indicates whether to include metadata in the results.

  • :parameters (Array<Types::SqlParameter>)

    The parameters for the SQL statement.

    Array parameters are not supported.

  • :resource_arn (required, String)

    The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

  • :result_set_options (Types::ResultSetOptions)

    Options that control how the result set is returned.

  • :schema (String)

    The name of the database schema.

  • :secret_arn (required, String)

    The name or ARN of the secret that enables access to the DB cluster.

  • :sql (required, String)

    The SQL statement to run.

  • :transaction_id (String)

    The identifier of a transaction that was started by using the BeginTransaction operation. Specify the transaction ID of the transaction that you want to include the SQL statement in.

    If the SQL statement is not part of a transaction, don\'t set this parameter.

Returns:

See Also:

#rollback_transaction(options = {}) ⇒ Types::RollbackTransactionResponse

Performs a rollback of a transaction. Rolling back a transaction cancels its changes.

Examples:

Request syntax with placeholder values


resp = client.rollback_transaction({
  resource_arn: "Arn", # required
  secret_arn: "Arn", # required
  transaction_id: "Id", # required
})

Response structure


resp.transaction_status #=> String

Options Hash (options):

  • :resource_arn (required, String)

    The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

  • :secret_arn (required, String)

    The name or ARN of the secret that enables access to the DB cluster.

  • :transaction_id (required, String)

    The identifier of the transaction to roll back.

Returns:

See Also:

#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

Parameters:

  • waiter_name (Symbol)

    The name of the waiter. See #waiter_names for a full list of supported waiters.

  • params (Hash) (defaults to: {})

    Additional request parameters. See the #waiter_names for a list of supported waiters and what request they call. The called request determines the list of accepted parameters.

Yield Parameters:

Returns:

  • (Boolean)

    Returns true if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.

#waiter_namesArray<Symbol>

Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:

Waiter NameClient MethodDefault Delay:Default Max Attempts:

Returns:

  • (Array<Symbol>)

    the list of supported waiters.