1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/core/utils/Outcome.h>
7 #include <aws/core/auth/AWSAuthSigner.h>
8 #include <aws/core/client/CoreErrors.h>
9 #include <aws/core/client/RetryStrategy.h>
10 #include <aws/core/http/HttpClient.h>
11 #include <aws/core/http/HttpResponse.h>
12 #include <aws/core/http/HttpClientFactory.h>
13 #include <aws/core/auth/AWSCredentialsProviderChain.h>
14 #include <aws/core/utils/json/JsonSerializer.h>
15 #include <aws/core/utils/memory/stl/AWSStringStream.h>
16 #include <aws/core/utils/threading/Executor.h>
17 #include <aws/core/utils/DNS.h>
18 #include <aws/core/utils/logging/LogMacros.h>
19
20 #include <aws/autoscaling-plans/AutoScalingPlansClient.h>
21 #include <aws/autoscaling-plans/AutoScalingPlansEndpoint.h>
22 #include <aws/autoscaling-plans/AutoScalingPlansErrorMarshaller.h>
23 #include <aws/autoscaling-plans/model/CreateScalingPlanRequest.h>
24 #include <aws/autoscaling-plans/model/DeleteScalingPlanRequest.h>
25 #include <aws/autoscaling-plans/model/DescribeScalingPlanResourcesRequest.h>
26 #include <aws/autoscaling-plans/model/DescribeScalingPlansRequest.h>
27 #include <aws/autoscaling-plans/model/GetScalingPlanResourceForecastDataRequest.h>
28 #include <aws/autoscaling-plans/model/UpdateScalingPlanRequest.h>
29
30 using namespace Aws;
31 using namespace Aws::Auth;
32 using namespace Aws::Client;
33 using namespace Aws::AutoScalingPlans;
34 using namespace Aws::AutoScalingPlans::Model;
35 using namespace Aws::Http;
36 using namespace Aws::Utils::Json;
37
38 static const char* SERVICE_NAME = "autoscaling-plans";
39 static const char* ALLOCATION_TAG = "AutoScalingPlansClient";
40
41
AutoScalingPlansClient(const Client::ClientConfiguration & clientConfiguration)42 AutoScalingPlansClient::AutoScalingPlansClient(const Client::ClientConfiguration& clientConfiguration) :
43 BASECLASS(clientConfiguration,
44 Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG),
45 SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
46 Aws::MakeShared<AutoScalingPlansErrorMarshaller>(ALLOCATION_TAG)),
47 m_executor(clientConfiguration.executor)
48 {
49 init(clientConfiguration);
50 }
51
AutoScalingPlansClient(const AWSCredentials & credentials,const Client::ClientConfiguration & clientConfiguration)52 AutoScalingPlansClient::AutoScalingPlansClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) :
53 BASECLASS(clientConfiguration,
54 Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<SimpleAWSCredentialsProvider>(ALLOCATION_TAG, credentials),
55 SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
56 Aws::MakeShared<AutoScalingPlansErrorMarshaller>(ALLOCATION_TAG)),
57 m_executor(clientConfiguration.executor)
58 {
59 init(clientConfiguration);
60 }
61
AutoScalingPlansClient(const std::shared_ptr<AWSCredentialsProvider> & credentialsProvider,const Client::ClientConfiguration & clientConfiguration)62 AutoScalingPlansClient::AutoScalingPlansClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
63 const Client::ClientConfiguration& clientConfiguration) :
64 BASECLASS(clientConfiguration,
65 Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, credentialsProvider,
66 SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
67 Aws::MakeShared<AutoScalingPlansErrorMarshaller>(ALLOCATION_TAG)),
68 m_executor(clientConfiguration.executor)
69 {
70 init(clientConfiguration);
71 }
72
~AutoScalingPlansClient()73 AutoScalingPlansClient::~AutoScalingPlansClient()
74 {
75 }
76
init(const Client::ClientConfiguration & config)77 void AutoScalingPlansClient::init(const Client::ClientConfiguration& config)
78 {
79 SetServiceClientName("Auto Scaling Plans");
80 m_configScheme = SchemeMapper::ToString(config.scheme);
81 if (config.endpointOverride.empty())
82 {
83 m_uri = m_configScheme + "://" + AutoScalingPlansEndpoint::ForRegion(config.region, config.useDualStack);
84 }
85 else
86 {
87 OverrideEndpoint(config.endpointOverride);
88 }
89 }
90
OverrideEndpoint(const Aws::String & endpoint)91 void AutoScalingPlansClient::OverrideEndpoint(const Aws::String& endpoint)
92 {
93 if (endpoint.compare(0, 7, "http://") == 0 || endpoint.compare(0, 8, "https://") == 0)
94 {
95 m_uri = endpoint;
96 }
97 else
98 {
99 m_uri = m_configScheme + "://" + endpoint;
100 }
101 }
102
CreateScalingPlan(const CreateScalingPlanRequest & request) const103 CreateScalingPlanOutcome AutoScalingPlansClient::CreateScalingPlan(const CreateScalingPlanRequest& request) const
104 {
105 Aws::Http::URI uri = m_uri;
106 return CreateScalingPlanOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
107 }
108
CreateScalingPlanCallable(const CreateScalingPlanRequest & request) const109 CreateScalingPlanOutcomeCallable AutoScalingPlansClient::CreateScalingPlanCallable(const CreateScalingPlanRequest& request) const
110 {
111 auto task = Aws::MakeShared< std::packaged_task< CreateScalingPlanOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->CreateScalingPlan(request); } );
112 auto packagedFunction = [task]() { (*task)(); };
113 m_executor->Submit(packagedFunction);
114 return task->get_future();
115 }
116
CreateScalingPlanAsync(const CreateScalingPlanRequest & request,const CreateScalingPlanResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const117 void AutoScalingPlansClient::CreateScalingPlanAsync(const CreateScalingPlanRequest& request, const CreateScalingPlanResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
118 {
119 m_executor->Submit( [this, request, handler, context](){ this->CreateScalingPlanAsyncHelper( request, handler, context ); } );
120 }
121
CreateScalingPlanAsyncHelper(const CreateScalingPlanRequest & request,const CreateScalingPlanResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const122 void AutoScalingPlansClient::CreateScalingPlanAsyncHelper(const CreateScalingPlanRequest& request, const CreateScalingPlanResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
123 {
124 handler(this, request, CreateScalingPlan(request), context);
125 }
126
DeleteScalingPlan(const DeleteScalingPlanRequest & request) const127 DeleteScalingPlanOutcome AutoScalingPlansClient::DeleteScalingPlan(const DeleteScalingPlanRequest& request) const
128 {
129 Aws::Http::URI uri = m_uri;
130 return DeleteScalingPlanOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
131 }
132
DeleteScalingPlanCallable(const DeleteScalingPlanRequest & request) const133 DeleteScalingPlanOutcomeCallable AutoScalingPlansClient::DeleteScalingPlanCallable(const DeleteScalingPlanRequest& request) const
134 {
135 auto task = Aws::MakeShared< std::packaged_task< DeleteScalingPlanOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->DeleteScalingPlan(request); } );
136 auto packagedFunction = [task]() { (*task)(); };
137 m_executor->Submit(packagedFunction);
138 return task->get_future();
139 }
140
DeleteScalingPlanAsync(const DeleteScalingPlanRequest & request,const DeleteScalingPlanResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const141 void AutoScalingPlansClient::DeleteScalingPlanAsync(const DeleteScalingPlanRequest& request, const DeleteScalingPlanResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
142 {
143 m_executor->Submit( [this, request, handler, context](){ this->DeleteScalingPlanAsyncHelper( request, handler, context ); } );
144 }
145
DeleteScalingPlanAsyncHelper(const DeleteScalingPlanRequest & request,const DeleteScalingPlanResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const146 void AutoScalingPlansClient::DeleteScalingPlanAsyncHelper(const DeleteScalingPlanRequest& request, const DeleteScalingPlanResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
147 {
148 handler(this, request, DeleteScalingPlan(request), context);
149 }
150
DescribeScalingPlanResources(const DescribeScalingPlanResourcesRequest & request) const151 DescribeScalingPlanResourcesOutcome AutoScalingPlansClient::DescribeScalingPlanResources(const DescribeScalingPlanResourcesRequest& request) const
152 {
153 Aws::Http::URI uri = m_uri;
154 return DescribeScalingPlanResourcesOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
155 }
156
DescribeScalingPlanResourcesCallable(const DescribeScalingPlanResourcesRequest & request) const157 DescribeScalingPlanResourcesOutcomeCallable AutoScalingPlansClient::DescribeScalingPlanResourcesCallable(const DescribeScalingPlanResourcesRequest& request) const
158 {
159 auto task = Aws::MakeShared< std::packaged_task< DescribeScalingPlanResourcesOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->DescribeScalingPlanResources(request); } );
160 auto packagedFunction = [task]() { (*task)(); };
161 m_executor->Submit(packagedFunction);
162 return task->get_future();
163 }
164
DescribeScalingPlanResourcesAsync(const DescribeScalingPlanResourcesRequest & request,const DescribeScalingPlanResourcesResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const165 void AutoScalingPlansClient::DescribeScalingPlanResourcesAsync(const DescribeScalingPlanResourcesRequest& request, const DescribeScalingPlanResourcesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
166 {
167 m_executor->Submit( [this, request, handler, context](){ this->DescribeScalingPlanResourcesAsyncHelper( request, handler, context ); } );
168 }
169
DescribeScalingPlanResourcesAsyncHelper(const DescribeScalingPlanResourcesRequest & request,const DescribeScalingPlanResourcesResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const170 void AutoScalingPlansClient::DescribeScalingPlanResourcesAsyncHelper(const DescribeScalingPlanResourcesRequest& request, const DescribeScalingPlanResourcesResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
171 {
172 handler(this, request, DescribeScalingPlanResources(request), context);
173 }
174
DescribeScalingPlans(const DescribeScalingPlansRequest & request) const175 DescribeScalingPlansOutcome AutoScalingPlansClient::DescribeScalingPlans(const DescribeScalingPlansRequest& request) const
176 {
177 Aws::Http::URI uri = m_uri;
178 return DescribeScalingPlansOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
179 }
180
DescribeScalingPlansCallable(const DescribeScalingPlansRequest & request) const181 DescribeScalingPlansOutcomeCallable AutoScalingPlansClient::DescribeScalingPlansCallable(const DescribeScalingPlansRequest& request) const
182 {
183 auto task = Aws::MakeShared< std::packaged_task< DescribeScalingPlansOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->DescribeScalingPlans(request); } );
184 auto packagedFunction = [task]() { (*task)(); };
185 m_executor->Submit(packagedFunction);
186 return task->get_future();
187 }
188
DescribeScalingPlansAsync(const DescribeScalingPlansRequest & request,const DescribeScalingPlansResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const189 void AutoScalingPlansClient::DescribeScalingPlansAsync(const DescribeScalingPlansRequest& request, const DescribeScalingPlansResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
190 {
191 m_executor->Submit( [this, request, handler, context](){ this->DescribeScalingPlansAsyncHelper( request, handler, context ); } );
192 }
193
DescribeScalingPlansAsyncHelper(const DescribeScalingPlansRequest & request,const DescribeScalingPlansResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const194 void AutoScalingPlansClient::DescribeScalingPlansAsyncHelper(const DescribeScalingPlansRequest& request, const DescribeScalingPlansResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
195 {
196 handler(this, request, DescribeScalingPlans(request), context);
197 }
198
GetScalingPlanResourceForecastData(const GetScalingPlanResourceForecastDataRequest & request) const199 GetScalingPlanResourceForecastDataOutcome AutoScalingPlansClient::GetScalingPlanResourceForecastData(const GetScalingPlanResourceForecastDataRequest& request) const
200 {
201 Aws::Http::URI uri = m_uri;
202 return GetScalingPlanResourceForecastDataOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
203 }
204
GetScalingPlanResourceForecastDataCallable(const GetScalingPlanResourceForecastDataRequest & request) const205 GetScalingPlanResourceForecastDataOutcomeCallable AutoScalingPlansClient::GetScalingPlanResourceForecastDataCallable(const GetScalingPlanResourceForecastDataRequest& request) const
206 {
207 auto task = Aws::MakeShared< std::packaged_task< GetScalingPlanResourceForecastDataOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->GetScalingPlanResourceForecastData(request); } );
208 auto packagedFunction = [task]() { (*task)(); };
209 m_executor->Submit(packagedFunction);
210 return task->get_future();
211 }
212
GetScalingPlanResourceForecastDataAsync(const GetScalingPlanResourceForecastDataRequest & request,const GetScalingPlanResourceForecastDataResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const213 void AutoScalingPlansClient::GetScalingPlanResourceForecastDataAsync(const GetScalingPlanResourceForecastDataRequest& request, const GetScalingPlanResourceForecastDataResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
214 {
215 m_executor->Submit( [this, request, handler, context](){ this->GetScalingPlanResourceForecastDataAsyncHelper( request, handler, context ); } );
216 }
217
GetScalingPlanResourceForecastDataAsyncHelper(const GetScalingPlanResourceForecastDataRequest & request,const GetScalingPlanResourceForecastDataResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const218 void AutoScalingPlansClient::GetScalingPlanResourceForecastDataAsyncHelper(const GetScalingPlanResourceForecastDataRequest& request, const GetScalingPlanResourceForecastDataResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
219 {
220 handler(this, request, GetScalingPlanResourceForecastData(request), context);
221 }
222
UpdateScalingPlan(const UpdateScalingPlanRequest & request) const223 UpdateScalingPlanOutcome AutoScalingPlansClient::UpdateScalingPlan(const UpdateScalingPlanRequest& request) const
224 {
225 Aws::Http::URI uri = m_uri;
226 return UpdateScalingPlanOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
227 }
228
UpdateScalingPlanCallable(const UpdateScalingPlanRequest & request) const229 UpdateScalingPlanOutcomeCallable AutoScalingPlansClient::UpdateScalingPlanCallable(const UpdateScalingPlanRequest& request) const
230 {
231 auto task = Aws::MakeShared< std::packaged_task< UpdateScalingPlanOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->UpdateScalingPlan(request); } );
232 auto packagedFunction = [task]() { (*task)(); };
233 m_executor->Submit(packagedFunction);
234 return task->get_future();
235 }
236
UpdateScalingPlanAsync(const UpdateScalingPlanRequest & request,const UpdateScalingPlanResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const237 void AutoScalingPlansClient::UpdateScalingPlanAsync(const UpdateScalingPlanRequest& request, const UpdateScalingPlanResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
238 {
239 m_executor->Submit( [this, request, handler, context](){ this->UpdateScalingPlanAsyncHelper( request, handler, context ); } );
240 }
241
UpdateScalingPlanAsyncHelper(const UpdateScalingPlanRequest & request,const UpdateScalingPlanResponseReceivedHandler & handler,const std::shared_ptr<const Aws::Client::AsyncCallerContext> & context) const242 void AutoScalingPlansClient::UpdateScalingPlanAsyncHelper(const UpdateScalingPlanRequest& request, const UpdateScalingPlanResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
243 {
244 handler(this, request, UpdateScalingPlan(request), context);
245 }
246
247