| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- /*
- * 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/iqa/IqaClient.h>
- #include <alibabacloud/core/SimpleCredentialsProvider.h>
- using namespace AlibabaCloud;
- using namespace AlibabaCloud::Location;
- using namespace AlibabaCloud::Iqa;
- using namespace AlibabaCloud::Iqa::Model;
- namespace
- {
- const std::string SERVICE_NAME = "iqa";
- }
- IqaClient::IqaClient(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, "iqa");
- }
- IqaClient::IqaClient(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, "iqa");
- }
- IqaClient::IqaClient(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, "iqa");
- }
- IqaClient::~IqaClient()
- {}
- IqaClient::CreateProjectOutcome IqaClient::createProject(const CreateProjectRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return CreateProjectOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return CreateProjectOutcome(CreateProjectResult(outcome.result()));
- else
- return CreateProjectOutcome(outcome.error());
- }
- void IqaClient::createProjectAsync(const CreateProjectRequest& request, const CreateProjectAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, createProject(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- IqaClient::CreateProjectOutcomeCallable IqaClient::createProjectCallable(const CreateProjectRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<CreateProjectOutcome()>>(
- [this, request]()
- {
- return this->createProject(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- IqaClient::DeleteProjectOutcome IqaClient::deleteProject(const DeleteProjectRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return DeleteProjectOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return DeleteProjectOutcome(DeleteProjectResult(outcome.result()));
- else
- return DeleteProjectOutcome(outcome.error());
- }
- void IqaClient::deleteProjectAsync(const DeleteProjectRequest& request, const DeleteProjectAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, deleteProject(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- IqaClient::DeleteProjectOutcomeCallable IqaClient::deleteProjectCallable(const DeleteProjectRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<DeleteProjectOutcome()>>(
- [this, request]()
- {
- return this->deleteProject(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- IqaClient::DeployServiceOutcome IqaClient::deployService(const DeployServiceRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return DeployServiceOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return DeployServiceOutcome(DeployServiceResult(outcome.result()));
- else
- return DeployServiceOutcome(outcome.error());
- }
- void IqaClient::deployServiceAsync(const DeployServiceRequest& request, const DeployServiceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, deployService(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- IqaClient::DeployServiceOutcomeCallable IqaClient::deployServiceCallable(const DeployServiceRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<DeployServiceOutcome()>>(
- [this, request]()
- {
- return this->deployService(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- IqaClient::DescribeProjectOutcome IqaClient::describeProject(const DescribeProjectRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return DescribeProjectOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return DescribeProjectOutcome(DescribeProjectResult(outcome.result()));
- else
- return DescribeProjectOutcome(outcome.error());
- }
- void IqaClient::describeProjectAsync(const DescribeProjectRequest& request, const DescribeProjectAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, describeProject(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- IqaClient::DescribeProjectOutcomeCallable IqaClient::describeProjectCallable(const DescribeProjectRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<DescribeProjectOutcome()>>(
- [this, request]()
- {
- return this->describeProject(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- IqaClient::GetPredictResultOutcome IqaClient::getPredictResult(const GetPredictResultRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return GetPredictResultOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return GetPredictResultOutcome(GetPredictResultResult(outcome.result()));
- else
- return GetPredictResultOutcome(outcome.error());
- }
- void IqaClient::getPredictResultAsync(const GetPredictResultRequest& request, const GetPredictResultAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, getPredictResult(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- IqaClient::GetPredictResultOutcomeCallable IqaClient::getPredictResultCallable(const GetPredictResultRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<GetPredictResultOutcome()>>(
- [this, request]()
- {
- return this->getPredictResult(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- IqaClient::ListProjectsOutcome IqaClient::listProjects(const ListProjectsRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return ListProjectsOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return ListProjectsOutcome(ListProjectsResult(outcome.result()));
- else
- return ListProjectsOutcome(outcome.error());
- }
- void IqaClient::listProjectsAsync(const ListProjectsRequest& request, const ListProjectsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, listProjects(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- IqaClient::ListProjectsOutcomeCallable IqaClient::listProjectsCallable(const ListProjectsRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<ListProjectsOutcome()>>(
- [this, request]()
- {
- return this->listProjects(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- IqaClient::ModifiyProjectOutcome IqaClient::modifiyProject(const ModifiyProjectRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return ModifiyProjectOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return ModifiyProjectOutcome(ModifiyProjectResult(outcome.result()));
- else
- return ModifiyProjectOutcome(outcome.error());
- }
- void IqaClient::modifiyProjectAsync(const ModifiyProjectRequest& request, const ModifiyProjectAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, modifiyProject(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- IqaClient::ModifiyProjectOutcomeCallable IqaClient::modifiyProjectCallable(const ModifiyProjectRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<ModifiyProjectOutcome()>>(
- [this, request]()
- {
- return this->modifiyProject(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- IqaClient::UploadDictionaryOutcome IqaClient::uploadDictionary(const UploadDictionaryRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return UploadDictionaryOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return UploadDictionaryOutcome(UploadDictionaryResult(outcome.result()));
- else
- return UploadDictionaryOutcome(outcome.error());
- }
- void IqaClient::uploadDictionaryAsync(const UploadDictionaryRequest& request, const UploadDictionaryAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, uploadDictionary(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- IqaClient::UploadDictionaryOutcomeCallable IqaClient::uploadDictionaryCallable(const UploadDictionaryRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<UploadDictionaryOutcome()>>(
- [this, request]()
- {
- return this->uploadDictionary(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
- IqaClient::UploadDocumentOutcome IqaClient::uploadDocument(const UploadDocumentRequest &request) const
- {
- auto endpointOutcome = endpointProvider_->getEndpoint();
- if (!endpointOutcome.isSuccess())
- return UploadDocumentOutcome(endpointOutcome.error());
- auto outcome = makeRequest(endpointOutcome.result(), request);
- if (outcome.isSuccess())
- return UploadDocumentOutcome(UploadDocumentResult(outcome.result()));
- else
- return UploadDocumentOutcome(outcome.error());
- }
- void IqaClient::uploadDocumentAsync(const UploadDocumentRequest& request, const UploadDocumentAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
- {
- auto fn = [this, request, handler, context]()
- {
- handler(this, request, uploadDocument(request), context);
- };
- asyncExecute(new Runnable(fn));
- }
- IqaClient::UploadDocumentOutcomeCallable IqaClient::uploadDocumentCallable(const UploadDocumentRequest &request) const
- {
- auto task = std::make_shared<std::packaged_task<UploadDocumentOutcome()>>(
- [this, request]()
- {
- return this->uploadDocument(request);
- });
- asyncExecute(new Runnable([task]() { (*task)(); }));
- return task->get_future();
- }
|