AWSSDK を使用して Aurora DB インスタンスのオプションを記述する - AWSSDK コードサンプル

AWSDocAWS SDKGitHub サンプルリポジトリには、さらに多くの SDK サンプルがあります


AWSSDK を使用して Aurora DB インスタンスのオプションを記述する

次のコード例は、Aurora DB インスタンスのオプションを記述する方法を示しています。


他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

/// <summary> /// Get a list of orderable DB instance options for a specific /// engine and engine version. /// </summary> /// <param name="engine">Name of the engine.</param> /// <param name="engineVersion">Version of the engine.</param> /// <returns>List of OrderableDBInstanceOptions.</returns> public async Task<List<OrderableDBInstanceOption>> DescribeOrderableDBInstanceOptionsPagedAsync(string engine, string engineVersion) { // Use a paginator to get a list of DB instance options. var results = new List<OrderableDBInstanceOption>(); var paginateInstanceOptions = _amazonRDS.Paginators.DescribeOrderableDBInstanceOptions( new DescribeOrderableDBInstanceOptionsRequest() { Engine = engine, EngineVersion = engineVersion, }); // Get the entire list using the paginator. await foreach (var instanceOptions in paginateInstanceOptions.OrderableDBInstanceOptions) { results.Add(instanceOptions); } return results; }
  • API の詳細については、AWS SDK for .NETAPIInstanceOptions リファレンスのDescribeOrderable DB を参照してください。

SDK for C++

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); //! Routine which gets available DB instance classes, displays the list //! to the user, and returns the user selection. /*! \sa chooseDBInstanceClass() \param engineName: The DB engine name. \param engineVersion: The DB engine version. \param dbInstanceClass: String for DB instance class chosen by the user. \param client: 'RDSClient' instance. \return bool: Successful completion. */ bool AwsDoc::Aurora::chooseDBInstanceClass(const Aws::String &engine, const Aws::String &engineVersion, Aws::String &dbInstanceClass, const Aws::RDS::RDSClient &client) { std::vector<Aws::String> instanceClasses; Aws::String marker; // The marker is used for pagination. do { Aws::RDS::Model::DescribeOrderableDBInstanceOptionsRequest request; request.SetEngine(engine); request.SetEngineVersion(engineVersion); if (!marker.empty()) { request.SetMarker(marker); } Aws::RDS::Model::DescribeOrderableDBInstanceOptionsOutcome outcome = client.DescribeOrderableDBInstanceOptions(request); if (outcome.IsSuccess()) { const Aws::Vector<Aws::RDS::Model::OrderableDBInstanceOption> &options = outcome.GetResult().GetOrderableDBInstanceOptions(); for (const Aws::RDS::Model::OrderableDBInstanceOption &option: options) { const Aws::String &instanceClass = option.GetDBInstanceClass(); instanceClasses.push_back(instanceClass); } marker = outcome.GetResult().GetMarker(); } else { std::cerr << "Error with Aurora::DescribeOrderableDBInstanceOptions. " << outcome.GetError().GetMessage() << std::endl; return false; } } while (!marker.empty()); std::cout << "The available DB instance classes for your database engine are:" << std::endl; for (int i = 0; i < instanceClasses.size(); ++i) { std::cout << " " << i + 1 << ": " << instanceClasses[i] << std::endl; } int choice = askQuestionForIntRange( "Which DB instance class do you want to use? ", 1, static_cast<int>(instanceClasses.size())); dbInstanceClass = instanceClasses[choice - 1]; return true; }
  • API の詳細については、AWS SDK for C++APIInstanceOptions リファレンスのDescribeOrderable DB を参照してください。

SDK for Java 2.x

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

public static void describeDBEngines( RdsClient rdsClient) { try { DescribeDbEngineVersionsRequest engineVersionsRequest = DescribeDbEngineVersionsRequest.builder() .engine("aurora-mysql") .defaultOnly(true) .maxRecords(20) .build(); DescribeDbEngineVersionsResponse response = rdsClient.describeDBEngineVersions(engineVersionsRequest); List<DBEngineVersion> engines = response.dbEngineVersions(); // Get all DBEngineVersion objects. for (DBEngineVersion engineOb: engines) { System.out.println("The name of the DB parameter group family for the database engine is "+engineOb.dbParameterGroupFamily()); System.out.println("The name of the database engine "+engineOb.engine()); System.out.println("The version number of the database engine "+engineOb.engineVersion()); } } catch (RdsException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
  • API の詳細については、AWS SDK for Java 2.xAPIInstanceOptions リファレンスのDescribeOrderable DB を参照してください。

SDK for Python (Boto3)

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

class AuroraWrapper: """Encapsulates Aurora DB cluster actions.""" def __init__(self, rds_client): """ :param rds_client: A Boto3 Amazon Relational Database Service (Amazon RDS) client. """ self.rds_client = rds_client @classmethod def from_client(cls): """ Instantiates this class from a Boto3 client. """ rds_client = boto3.client('rds') return cls(rds_client) def get_orderable_instances(self, db_engine, db_engine_version): """ Gets DB instance options that can be used to create DB instances that are compatible with a set of specifications. :param db_engine: The database engine that must be supported by the DB instance. :param db_engine_version: The engine version that must be supported by the DB instance. :return: The list of DB instance options that can be used to create a compatible DB instance. """ try: inst_opts = [] paginator = self.rds_client.get_paginator('describe_orderable_db_instance_options') for page in paginator.paginate(Engine=db_engine, EngineVersion=db_engine_version): inst_opts += page['OrderableDBInstanceOptions'] except ClientError as err: logger.error( "Couldn't get orderable DB instances. Here's why: %s: %s", err.response['Error']['Code'], err.response['Error']['Message']) raise else: return inst_opts