in identity/source/IotIdentityClientV2.cpp [224:284]
bool ClientV2::CreateKeysAndCertificate(
const CreateKeysAndCertificateRequest &request,
const CreateKeysAndCertificateResultHandler &handler)
{
Aws::Crt::StringStream publishTopicStream;
publishTopicStream << "$aws/certificates/create/json";
Aws::Crt::String publishTopic = publishTopicStream.str();
Aws::Crt::StringStream subscriptionTopicStream0;
subscriptionTopicStream0 << "$aws/certificates/create/json/accepted";
Aws::Crt::String subscriptionTopic0 = subscriptionTopicStream0.str();
Aws::Crt::StringStream subscriptionTopicStream1;
subscriptionTopicStream1 << "$aws/certificates/create/json/rejected";
Aws::Crt::String subscriptionTopic1 = subscriptionTopicStream1.str();
struct aws_byte_cursor subscriptionTopicFilters[2] = {
Aws::Crt::ByteCursorFromString(subscriptionTopic0),
Aws::Crt::ByteCursorFromString(subscriptionTopic1),
};
Aws::Crt::StringStream responsePathTopicAcceptedStream;
responsePathTopicAcceptedStream << publishTopic << "/accepted";
Aws::Crt::String responsePathTopicAccepted = responsePathTopicAcceptedStream.str();
Aws::Crt::StringStream responsePathTopicRejectedStream;
responsePathTopicRejectedStream << publishTopic << "/rejected";
Aws::Crt::String responsePathTopicRejected = responsePathTopicRejectedStream.str();
struct aws_mqtt_request_operation_response_path responsePaths[2];
responsePaths[0].topic = Aws::Crt::ByteCursorFromString(responsePathTopicAccepted);
responsePaths[1].topic = Aws::Crt::ByteCursorFromString(responsePathTopicRejected);
AWS_ZERO_STRUCT(responsePaths[0].correlation_token_json_path);
AWS_ZERO_STRUCT(responsePaths[1].correlation_token_json_path);
Aws::Crt::JsonObject jsonObject;
request.SerializeToObject(jsonObject);
Aws::Crt::String outgoingJson = jsonObject.View().WriteCompact(true);
struct aws_mqtt_request_operation_options options;
AWS_ZERO_STRUCT(options);
options.subscription_topic_filters = subscriptionTopicFilters;
options.subscription_topic_filter_count = 2;
options.response_paths = responsePaths;
options.response_path_count = 2;
options.publish_topic = Aws::Crt::ByteCursorFromString(publishTopic);
options.serialized_request =
Aws::Crt::ByteCursorFromArray((uint8_t *)outgoingJson.data(), outgoingJson.length());
auto resultHandler = [handler, responsePathTopicAccepted, responsePathTopicRejected](
Aws::Iot::RequestResponse::UnmodeledResult &&result)
{
s_CreateKeysAndCertificateResponseHandler(
std::move(result), handler, responsePathTopicAccepted, responsePathTopicRejected);
};
int submitResult = m_bindingClient->SubmitRequest(options, std::move(resultHandler));
return submitResult == AWS_OP_SUCCESS;
}