AWSSDK を使用して ACM 証明書を一覧表示する - AWSSDK コードサンプル

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

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AWSSDK を使用して ACM 証明書を一覧表示する

次のコード例は、ACM 証明書を一覧表示する方法を示しています。

.NET
AWS SDK for .NET
注記

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

using Amazon; using Amazon.CertificateManager; using Amazon.CertificateManager.Model; using System; using System.Threading.Tasks; namespace ListCertificates { // The following example retrieves and displays a list of the // certificates defined for the default account using the AWS // Certificate Manager (ACM) service. It was created using // AWS SDK for .NET 3.5 and .NET 5.0. class ListCertificates { // Specify your AWS Region (an example Region is shown). private static readonly RegionEndpoint ACMRegion = RegionEndpoint.USEast1; private static AmazonCertificateManagerClient _client; static void Main(string[] args) { var _client = new AmazonCertificateManagerClient(ACMRegion); var certificateList = ListCertificatesResponseAsync(client: _client); Console.WriteLine("Certificate Summary List\n"); foreach (var certificate in certificateList.Result.CertificateSummaryList) { Console.WriteLine($"Certificate Domain: {certificate.DomainName}"); Console.WriteLine($"Certificate ARN: {certificate.CertificateArn}\n"); } } /// <summary> /// Retrieves a list of the certificates defined in this Region. /// </summary> /// <param name="client">The ACM client object passed to the /// ListCertificateResAsync method call.</param> /// <param name="request"></param> /// <returns>The ListCertificatesResponse.</returns> static async Task<ListCertificatesResponse> ListCertificatesResponseAsync( AmazonCertificateManagerClient client) { var request = new ListCertificatesRequest(); var response = await client.ListCertificatesAsync(request); return response; } } }
  • API の詳細については、AWS SDK for .NETAPI ListCertificatesリファレンスのを参照してください

Python
SDK for Python (Boto3)
注記

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

class AcmCertificate: """ Encapsulates ACM functions. """ def __init__(self, acm_client): """ :param acm_client: A Boto3 ACM client. """ self.acm_client = acm_client def list( self, max_items, statuses=None, key_usage=None, extended_key_usage=None, key_types=None): """ Lists the certificates for the current account. :param max_items: The maximum number of certificates to list. :param statuses: Filters the results to the specified statuses. If None, all certificates are included. :param key_usage: Filters the results to the specified key usages. If None, all key usages are included. :param extended_key_usage: Filters the results to the specified extended key usages. If None, all extended key usages are included. :param key_types: Filters the results to the specified key types. If None, all key types are included. :return: The list of certificates. """ try: kwargs = {'MaxItems': max_items} if statuses is not None: kwargs['CertificateStatuses'] = statuses includes = {} if key_usage is not None: includes['keyUsage'] = key_usage if extended_key_usage is not None: includes['extendedKeyUsage'] = extended_key_usage if key_types is not None: includes['keyTypes'] = key_types if includes: kwargs['Includes'] = includes response = self.acm_client.list_certificates(**kwargs) certificates = response['CertificateSummaryList'] logger.info("Got %s certificates.", len(certificates)) except ClientError: logger.exception("Couldn't get certificates.") raise else: return certificates
  • API の詳細については、「AWSSDK for Python (Boto3) API リファレンス」のを参照してくださいListCertificates