| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- /*
- * Copyright 2009-2017 Alibaba Cloud All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #include <alibabacloud/ecs-workbench/Ecs_workbenchClient.h>
- #include <alibabacloud/core/SimpleCredentialsProvider.h>
- using namespace AlibabaCloud;
- using namespace AlibabaCloud::Location;
- using namespace AlibabaCloud::Ecs_workbench;
- using namespace AlibabaCloud::Ecs_workbench::Model;
- namespace
- {
- const std::string SERVICE_NAME = "ecs-workbench";
- }
- Ecs_workbenchClient::Ecs_workbenchClient(const Credentials &credentials, const ClientConfiguration &configuration) :
- RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
- {
- auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
- endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "ecs-workbench");
- }
- Ecs_workbenchClient::Ecs_workbenchClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
- RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
- {
- auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
- endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "ecs-workbench");
- }
- Ecs_workbenchClient::Ecs_workbenchClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
- RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
- {
- auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
- endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "ecs-workbench");
- }
- Ecs_workbenchClient::~Ecs_workbenchClient()
- {}
- Ecs_workbenchClient::GetInstanceRecordConfigOutcome Ecs_workbenchClient::getInstanceRecordConfig(const GetInstanceRecordConfigRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return GetInstanceRecordConfigOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return GetInstanceRecordConfigOutcome(GetInstanceRecordConfigResult(outcome.result()));
- else
- return GetInstanceRecordConfigOutcome(outcome.error());
- }
- void Ecs_workbenchClient::getInstanceRecordConfigAsync(const GetInstanceRecordConfigRequest& request, const GetInstanceRecordConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, getInstanceRecordConfig(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- Ecs_workbenchClient::GetInstanceRecordConfigOutcomeCallable Ecs_workbenchClient::getInstanceRecordConfigCallable(const GetInstanceRecordConfigRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<GetInstanceRecordConfigOutcome()>>(
- [this, request]()
- {
- return this->getInstanceRecordConfig(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- Ecs_workbenchClient::ListInstanceRecordsOutcome Ecs_workbenchClient::listInstanceRecords(const ListInstanceRecordsRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return ListInstanceRecordsOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return ListInstanceRecordsOutcome(ListInstanceRecordsResult(outcome.result()));
- else
- return ListInstanceRecordsOutcome(outcome.error());
- }
- void Ecs_workbenchClient::listInstanceRecordsAsync(const ListInstanceRecordsRequest& request, const ListInstanceRecordsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, listInstanceRecords(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- Ecs_workbenchClient::ListInstanceRecordsOutcomeCallable Ecs_workbenchClient::listInstanceRecordsCallable(const ListInstanceRecordsRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<ListInstanceRecordsOutcome()>>(
- [this, request]()
- {
- return this->listInstanceRecords(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- Ecs_workbenchClient::LoginInstanceOutcome Ecs_workbenchClient::loginInstance(const LoginInstanceRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return LoginInstanceOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return LoginInstanceOutcome(LoginInstanceResult(outcome.result()));
- else
- return LoginInstanceOutcome(outcome.error());
- }
- void Ecs_workbenchClient::loginInstanceAsync(const LoginInstanceRequest& request, const LoginInstanceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, loginInstance(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- Ecs_workbenchClient::LoginInstanceOutcomeCallable Ecs_workbenchClient::loginInstanceCallable(const LoginInstanceRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<LoginInstanceOutcome()>>(
- [this, request]()
- {
- return this->loginInstance(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- Ecs_workbenchClient::SetInstanceRecordConfigOutcome Ecs_workbenchClient::setInstanceRecordConfig(const SetInstanceRecordConfigRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return SetInstanceRecordConfigOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return SetInstanceRecordConfigOutcome(SetInstanceRecordConfigResult(outcome.result()));
- else
- return SetInstanceRecordConfigOutcome(outcome.error());
- }
- void Ecs_workbenchClient::setInstanceRecordConfigAsync(const SetInstanceRecordConfigRequest& request, const SetInstanceRecordConfigAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, setInstanceRecordConfig(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- Ecs_workbenchClient::SetInstanceRecordConfigOutcomeCallable Ecs_workbenchClient::setInstanceRecordConfigCallable(const SetInstanceRecordConfigRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<SetInstanceRecordConfigOutcome()>>(
- [this, request]()
- {
- return this->setInstanceRecordConfig(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- Ecs_workbenchClient::ViewInstanceRecordsOutcome Ecs_workbenchClient::viewInstanceRecords(const ViewInstanceRecordsRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return ViewInstanceRecordsOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return ViewInstanceRecordsOutcome(ViewInstanceRecordsResult(outcome.result()));
- else
- return ViewInstanceRecordsOutcome(outcome.error());
- }
- void Ecs_workbenchClient::viewInstanceRecordsAsync(const ViewInstanceRecordsRequest& request, const ViewInstanceRecordsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, viewInstanceRecords(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- Ecs_workbenchClient::ViewInstanceRecordsOutcomeCallable Ecs_workbenchClient::viewInstanceRecordsCallable(const ViewInstanceRecordsRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<ViewInstanceRecordsOutcome()>>(
- [this, request]()
- {
- return this->viewInstanceRecords(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
|