Repository navigation
Expand file tree
/
Copy pathEC2ProtocolClient.cpp
More file actions
302 lines (261 loc) · 17.9 KB
/
Copy pathEC2ProtocolClient.cpp
File metadata and controls
302 lines (261 loc) · 17.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/core/client/RetryStrategy.h>
#include <aws/core/http/HttpClient.h>
#include <aws/core/http/HttpClientFactory.h>
#include <aws/core/http/HttpResponse.h>
#include <aws/core/utils/DNS.h>
#include <aws/core/utils/Outcome.h>
#include <aws/core/utils/logging/ErrorMacros.h>
#include <aws/core/utils/logging/LogMacros.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/threading/Executor.h>
#include <aws/core/utils/xml/XmlSerializer.h>
#include <aws/ec2-protocol/EC2ProtocolClient.h>
#include <aws/ec2-protocol/EC2ProtocolEndpointProvider.h>
#include <aws/ec2-protocol/EC2ProtocolErrorMarshaller.h>
#include <aws/ec2-protocol/model/DatetimeOffsetsRequest.h>
#include <aws/ec2-protocol/model/EmptyInputAndEmptyOutputRequest.h>
#include <aws/ec2-protocol/model/EndpointOperationRequest.h>
#include <aws/ec2-protocol/model/EndpointWithHostLabelOperationRequest.h>
#include <aws/ec2-protocol/model/FractionalSecondsRequest.h>
#include <aws/ec2-protocol/model/GreetingWithErrorsRequest.h>
#include <aws/ec2-protocol/model/HostWithPathOperationRequest.h>
#include <aws/ec2-protocol/model/IgnoresWrappingXmlNameRequest.h>
#include <aws/ec2-protocol/model/NestedStructuresRequest.h>
#include <aws/ec2-protocol/model/NoInputAndOutputRequest.h>
#include <aws/ec2-protocol/model/PutWithContentEncodingRequest.h>
#include <aws/ec2-protocol/model/QueryIdempotencyTokenAutoFillRequest.h>
#include <aws/ec2-protocol/model/QueryListsRequest.h>
#include <aws/ec2-protocol/model/QueryTimestampsRequest.h>
#include <aws/ec2-protocol/model/RecursiveXmlShapesRequest.h>
#include <aws/ec2-protocol/model/SimpleInputParamsRequest.h>
#include <aws/ec2-protocol/model/SimpleScalarXmlPropertiesRequest.h>
#include <aws/ec2-protocol/model/XmlBlobsRequest.h>
#include <aws/ec2-protocol/model/XmlEmptyBlobsRequest.h>
#include <aws/ec2-protocol/model/XmlEmptyListsRequest.h>
#include <aws/ec2-protocol/model/XmlEnumsRequest.h>
#include <aws/ec2-protocol/model/XmlIntEnumsRequest.h>
#include <aws/ec2-protocol/model/XmlListsRequest.h>
#include <aws/ec2-protocol/model/XmlNamespacesRequest.h>
#include <aws/ec2-protocol/model/XmlTimestampsRequest.h>
#include <smithy/tracing/TracingUtils.h>
using namespace Aws;
using namespace Aws::Auth;
using namespace Aws::Client;
using namespace Aws::EC2Protocol;
using namespace Aws::EC2Protocol::Model;
using namespace Aws::Http;
using namespace Aws::Utils::Xml;
using namespace smithy::components::tracing;
using ResolveEndpointOutcome = Aws::Endpoint::ResolveEndpointOutcome;
namespace Aws {
namespace EC2Protocol {
const char SERVICE_NAME[] = "ec2query";
const char ALLOCATION_TAG[] = "EC2ProtocolClient";
} // namespace EC2Protocol
} // namespace Aws
const char* EC2ProtocolClient::GetServiceName() { return SERVICE_NAME; }
const char* EC2ProtocolClient::GetAllocationTag() { return ALLOCATION_TAG; }
EC2ProtocolClient::EC2ProtocolClient(const EC2Protocol::EC2ProtocolClientConfiguration& clientConfiguration,
std::shared_ptr<EC2ProtocolEndpointProviderBase> endpointProvider)
: BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG,
Aws::MakeShared<DefaultAWSCredentialsProviderChain>(
ALLOCATION_TAG, clientConfiguration.ResolveCredentialProviderConfig()),
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<EC2ProtocolErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<EC2ProtocolEndpointProvider>(ALLOCATION_TAG)) {
init(m_clientConfiguration);
}
EC2ProtocolClient::EC2ProtocolClient(const AWSCredentials& credentials, std::shared_ptr<EC2ProtocolEndpointProviderBase> endpointProvider,
const EC2Protocol::EC2ProtocolClientConfiguration& clientConfiguration)
: BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<SimpleAWSCredentialsProvider>(ALLOCATION_TAG, credentials),
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<EC2ProtocolErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<EC2ProtocolEndpointProvider>(ALLOCATION_TAG)) {
init(m_clientConfiguration);
}
EC2ProtocolClient::EC2ProtocolClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
std::shared_ptr<EC2ProtocolEndpointProviderBase> endpointProvider,
const EC2Protocol::EC2ProtocolClientConfiguration& clientConfiguration)
: BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, credentialsProvider, SERVICE_NAME,
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<EC2ProtocolErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<EC2ProtocolEndpointProvider>(ALLOCATION_TAG)) {
init(m_clientConfiguration);
}
EC2ProtocolClient::~EC2ProtocolClient() { ShutdownSdkClient(this, -1); }
std::shared_ptr<EC2ProtocolEndpointProviderBase>& EC2ProtocolClient::accessEndpointProvider() { return m_endpointProvider; }
void EC2ProtocolClient::init(const EC2Protocol::EC2ProtocolClientConfiguration& config) {
AWSClient::SetServiceClientName("EC2 Protocol");
if (!m_clientConfiguration.executor && m_clientConfiguration.configFactories.executorCreateFn) {
m_clientConfiguration.executor = m_clientConfiguration.configFactories.executorCreateFn();
}
if (!m_clientConfiguration.executor) {
AWS_LOGSTREAM_FATAL(ALLOCATION_TAG, "Failed to initialize client: config is missing Executor or executorCreateFn");
m_isInitialized = false;
return;
}
AWSClient::SetUserAgentExecutor(*m_clientConfiguration.executor);
AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider);
m_endpointProvider->InitBuiltInParameters(config, "ec2query");
ApplyServiceOptions(GetServiceClientOptions(m_clientConfiguration));
}
EC2ProtocolClient::InvokeOperationOutcome EC2ProtocolClient::InvokeServiceOperation(const AmazonWebServiceRequest& request,
Aws::Http::HttpMethod httpMethod) const {
auto operationName = request.GetServiceRequestName();
auto serviceName = GetServiceClientName();
AWS_OPERATION_GUARD_DYNAMIC(operationName);
AWS_OPERATION_CHECK_PTR_DYNAMIC(m_endpointProvider, operationName, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE);
AWS_OPERATION_CHECK_PTR_DYNAMIC(m_telemetryProvider, operationName, CoreErrors, CoreErrors::NOT_INITIALIZED);
auto tracer = m_telemetryProvider->getTracer(serviceName, {});
auto meter = m_telemetryProvider->getMeter(serviceName, {});
AWS_OPERATION_CHECK_PTR_DYNAMIC(meter, operationName, CoreErrors, CoreErrors::NOT_INITIALIZED);
auto span = tracer->CreateSpan(Aws::String(serviceName) + "." + operationName,
{{TracingUtils::SMITHY_METHOD_DIMENSION, operationName},
{TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName},
{TracingUtils::SMITHY_SYSTEM_DIMENSION, TracingUtils::SMITHY_METHOD_AWS_VALUE}},
smithy::components::tracing::SpanKind::CLIENT);
return Aws::Client::AsyncOperationState::MakeCallWithTiming<InvokeOperationOutcome>(
request, std::move(span),
[&]() -> InvokeOperationOutcome {
auto endpointResolutionOutcome = TracingUtils::MakeCallWithTiming<ResolveEndpointOutcome>(
[&]() -> ResolveEndpointOutcome { return m_endpointProvider->ResolveEndpoint(request.GetEndpointContextParams()); },
TracingUtils::SMITHY_CLIENT_ENDPOINT_RESOLUTION_METRIC, *meter,
{{TracingUtils::SMITHY_METHOD_DIMENSION, operationName}, {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}});
AWS_OPERATION_CHECK_SUCCESS_DYNAMIC(endpointResolutionOutcome, operationName, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE,
endpointResolutionOutcome.GetError().GetMessage());
return InvokeOperationOutcome{MakeRequest(request, endpointResolutionOutcome.GetResult(), httpMethod, Aws::Auth::SIGV4_SIGNER)};
},
TracingUtils::SMITHY_CLIENT_DURATION_METRIC, meter,
{{TracingUtils::SMITHY_METHOD_DIMENSION, operationName}, {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}});
}
DatetimeOffsetsOutcome EC2ProtocolClient::DatetimeOffsets(const DatetimeOffsetsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? DatetimeOffsetsOutcome(result.GetResultWithOwnership())
: DatetimeOffsetsOutcome(std::move(result.GetError()));
}
EmptyInputAndEmptyOutputOutcome EC2ProtocolClient::EmptyInputAndEmptyOutput(const EmptyInputAndEmptyOutputRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? EmptyInputAndEmptyOutputOutcome(result.GetResultWithOwnership())
: EmptyInputAndEmptyOutputOutcome(std::move(result.GetError()));
}
EndpointOperationOutcome EC2ProtocolClient::EndpointOperation(const EndpointOperationRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? EndpointOperationOutcome(result.GetResultWithOwnership())
: EndpointOperationOutcome(std::move(result.GetError()));
}
EndpointWithHostLabelOperationOutcome EC2ProtocolClient::EndpointWithHostLabelOperation(
const EndpointWithHostLabelOperationRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? EndpointWithHostLabelOperationOutcome(result.GetResultWithOwnership())
: EndpointWithHostLabelOperationOutcome(std::move(result.GetError()));
}
FractionalSecondsOutcome EC2ProtocolClient::FractionalSeconds(const FractionalSecondsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? FractionalSecondsOutcome(result.GetResultWithOwnership())
: FractionalSecondsOutcome(std::move(result.GetError()));
}
GreetingWithErrorsOutcome EC2ProtocolClient::GreetingWithErrors(const GreetingWithErrorsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? GreetingWithErrorsOutcome(result.GetResultWithOwnership())
: GreetingWithErrorsOutcome(std::move(result.GetError()));
}
HostWithPathOperationOutcome EC2ProtocolClient::HostWithPathOperation(const HostWithPathOperationRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? HostWithPathOperationOutcome(result.GetResultWithOwnership())
: HostWithPathOperationOutcome(std::move(result.GetError()));
}
IgnoresWrappingXmlNameOutcome EC2ProtocolClient::IgnoresWrappingXmlName(const IgnoresWrappingXmlNameRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? IgnoresWrappingXmlNameOutcome(result.GetResultWithOwnership())
: IgnoresWrappingXmlNameOutcome(std::move(result.GetError()));
}
NestedStructuresOutcome EC2ProtocolClient::NestedStructures(const NestedStructuresRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? NestedStructuresOutcome(result.GetResultWithOwnership())
: NestedStructuresOutcome(std::move(result.GetError()));
}
NoInputAndOutputOutcome EC2ProtocolClient::NoInputAndOutput(const NoInputAndOutputRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? NoInputAndOutputOutcome(result.GetResultWithOwnership())
: NoInputAndOutputOutcome(std::move(result.GetError()));
}
PutWithContentEncodingOutcome EC2ProtocolClient::PutWithContentEncoding(const PutWithContentEncodingRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? PutWithContentEncodingOutcome(result.GetResultWithOwnership())
: PutWithContentEncodingOutcome(std::move(result.GetError()));
}
QueryIdempotencyTokenAutoFillOutcome EC2ProtocolClient::QueryIdempotencyTokenAutoFill(
const QueryIdempotencyTokenAutoFillRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? QueryIdempotencyTokenAutoFillOutcome(result.GetResultWithOwnership())
: QueryIdempotencyTokenAutoFillOutcome(std::move(result.GetError()));
}
QueryListsOutcome EC2ProtocolClient::QueryLists(const QueryListsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? QueryListsOutcome(result.GetResultWithOwnership()) : QueryListsOutcome(std::move(result.GetError()));
}
QueryTimestampsOutcome EC2ProtocolClient::QueryTimestamps(const QueryTimestampsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? QueryTimestampsOutcome(result.GetResultWithOwnership())
: QueryTimestampsOutcome(std::move(result.GetError()));
}
RecursiveXmlShapesOutcome EC2ProtocolClient::RecursiveXmlShapes(const RecursiveXmlShapesRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? RecursiveXmlShapesOutcome(result.GetResultWithOwnership())
: RecursiveXmlShapesOutcome(std::move(result.GetError()));
}
SimpleInputParamsOutcome EC2ProtocolClient::SimpleInputParams(const SimpleInputParamsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? SimpleInputParamsOutcome(result.GetResultWithOwnership())
: SimpleInputParamsOutcome(std::move(result.GetError()));
}
SimpleScalarXmlPropertiesOutcome EC2ProtocolClient::SimpleScalarXmlProperties(const SimpleScalarXmlPropertiesRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? SimpleScalarXmlPropertiesOutcome(result.GetResultWithOwnership())
: SimpleScalarXmlPropertiesOutcome(std::move(result.GetError()));
}
XmlBlobsOutcome EC2ProtocolClient::XmlBlobs(const XmlBlobsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? XmlBlobsOutcome(result.GetResultWithOwnership()) : XmlBlobsOutcome(std::move(result.GetError()));
}
XmlEmptyBlobsOutcome EC2ProtocolClient::XmlEmptyBlobs(const XmlEmptyBlobsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? XmlEmptyBlobsOutcome(result.GetResultWithOwnership()) : XmlEmptyBlobsOutcome(std::move(result.GetError()));
}
XmlEmptyListsOutcome EC2ProtocolClient::XmlEmptyLists(const XmlEmptyListsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? XmlEmptyListsOutcome(result.GetResultWithOwnership()) : XmlEmptyListsOutcome(std::move(result.GetError()));
}
XmlEnumsOutcome EC2ProtocolClient::XmlEnums(const XmlEnumsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? XmlEnumsOutcome(result.GetResultWithOwnership()) : XmlEnumsOutcome(std::move(result.GetError()));
}
XmlIntEnumsOutcome EC2ProtocolClient::XmlIntEnums(const XmlIntEnumsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? XmlIntEnumsOutcome(result.GetResultWithOwnership()) : XmlIntEnumsOutcome(std::move(result.GetError()));
}
XmlListsOutcome EC2ProtocolClient::XmlLists(const XmlListsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? XmlListsOutcome(result.GetResultWithOwnership()) : XmlListsOutcome(std::move(result.GetError()));
}
XmlNamespacesOutcome EC2ProtocolClient::XmlNamespaces(const XmlNamespacesRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? XmlNamespacesOutcome(result.GetResultWithOwnership()) : XmlNamespacesOutcome(std::move(result.GetError()));
}
XmlTimestampsOutcome EC2ProtocolClient::XmlTimestamps(const XmlTimestampsRequest& request) const {
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
return result.IsSuccess() ? XmlTimestampsOutcome(result.GetResultWithOwnership()) : XmlTimestampsOutcome(std::move(result.GetError()));
}