// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 /** * Before running this C++ code example, set up your development environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/getting-started.html * * For information on the structure of the code examples and how to build and run the examples, see * https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/getting-started-code-examples.html. * **/ #include #include #include "acm_samples.h" // snippet-start:[cpp.example_code.acm.RequestCertificate] //! Request an AWS Certificate Manager (ACM) certificate. /*! \param domainName: A fully qualified domain name. \param idempotencyToken: Customer chosen string for idempotency. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::requestCertificate(const Aws::String &domainName, const Aws::String &idempotencyToken, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::RequestCertificateRequest request; request.WithDomainName(domainName) .WithIdempotencyToken(idempotencyToken); Aws::ACM::Model::RequestCertificateOutcome outcome = acmClient.RequestCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "RequestCertificate error: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: The newly requested certificate's " "ARN is '" << outcome.GetResult().GetCertificateArn() << "'." << std::endl; return true; } } // snippet-end:[cpp.example_code.acm.RequestCertificate] /* * * main function * * Usage: 'run_request_certificate ' * */ #ifndef TESTING_BUILD int main(int argc, char **argv) { if (argc != 3) { std::cout << "Usage: 'run_request_certificate '" << std::endl; return 1; } Aws::SDKOptions options; Aws::InitAPI(options); { Aws::String domainName = argv[1]; Aws::String idempotencyToken = argv[2]; Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; AwsDoc::ACM::requestCertificate(domainName, idempotencyToken, clientConfig); } Aws::ShutdownAPI(options); return 0; } #endif // TESTING_BUILD