SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 40 Java
2024-03-11 18:26:55 -04:00
// 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 <aws/acm/ACMClient.h>
#include <aws/acm/model/RequestCertificateRequest.h>
#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 <domain_name> <idempotency_token>'
*
*/
#ifndef TESTING_BUILD
int main(int argc, char **argv) {
if (argc != 3) {
std::cout
<< "Usage: 'run_request_certificate <domain_name> <idempotency_token>'"
<< 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