| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- /*
- * 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/wfts/WftsClient.h>
- #include <alibabacloud/core/SimpleCredentialsProvider.h>
- using namespace AlibabaCloud;
- using namespace AlibabaCloud::Location;
- using namespace AlibabaCloud::Wfts;
- using namespace AlibabaCloud::Wfts::Model;
- namespace
- {
- const std::string SERVICE_NAME = "Wfts";
- }
- WftsClient::WftsClient(const Credentials &credentials, const ClientConfiguration &configuration) :
- RoaServiceClient(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, "");
- }
- WftsClient::WftsClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
- RoaServiceClient(SERVICE_NAME, credentialsProvider, configuration)
- {
- auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
- endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
- }
- WftsClient::WftsClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
- RoaServiceClient(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, "");
- }
- WftsClient::~WftsClient()
- {}
- WftsClient::GetLjxAccountInfoOutcome WftsClient::getLjxAccountInfo(const GetLjxAccountInfoRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return GetLjxAccountInfoOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return GetLjxAccountInfoOutcome(GetLjxAccountInfoResult(outcome.result()));
- else
- return GetLjxAccountInfoOutcome(outcome.error());
- }
- void WftsClient::getLjxAccountInfoAsync(const GetLjxAccountInfoRequest& request, const GetLjxAccountInfoAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, getLjxAccountInfo(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- WftsClient::GetLjxAccountInfoOutcomeCallable WftsClient::getLjxAccountInfoCallable(const GetLjxAccountInfoRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<GetLjxAccountInfoOutcome()>>(
- [this, request]()
- {
- return this->getLjxAccountInfo(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
|