Initialize SDK.

This commit is contained in:
sdk-team
2023-08-01 06:40:39 +00:00
parent a09f60b542
commit bce94a0fa4
21 changed files with 1374 additions and 1 deletions

197
grace/src/GraceClient.cc Normal file
View File

@@ -0,0 +1,197 @@
/*
* 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/grace/GraceClient.h>
#include <alibabacloud/core/SimpleCredentialsProvider.h>
using namespace AlibabaCloud;
using namespace AlibabaCloud::Location;
using namespace AlibabaCloud::Grace;
using namespace AlibabaCloud::Grace::Model;
namespace
{
const std::string SERVICE_NAME = "grace";
}
GraceClient::GraceClient(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, "grace");
}
GraceClient::GraceClient(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, "grace");
}
GraceClient::GraceClient(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, "grace");
}
GraceClient::~GraceClient()
{}
GraceClient::AnalyzeFileOutcome GraceClient::analyzeFile(const AnalyzeFileRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return AnalyzeFileOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return AnalyzeFileOutcome(AnalyzeFileResult(outcome.result()));
else
return AnalyzeFileOutcome(outcome.error());
}
void GraceClient::analyzeFileAsync(const AnalyzeFileRequest& request, const AnalyzeFileAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, analyzeFile(request), context);
};
asyncExecute(new Runnable(fn));
}
GraceClient::AnalyzeFileOutcomeCallable GraceClient::analyzeFileCallable(const AnalyzeFileRequest &request) const
{
auto task = std::make_shared<std::packaged_task<AnalyzeFileOutcome()>>(
[this, request]()
{
return this->analyzeFile(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
GraceClient::GetFileOutcome GraceClient::getFile(const GetFileRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return GetFileOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return GetFileOutcome(GetFileResult(outcome.result()));
else
return GetFileOutcome(outcome.error());
}
void GraceClient::getFileAsync(const GetFileRequest& request, const GetFileAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, getFile(request), context);
};
asyncExecute(new Runnable(fn));
}
GraceClient::GetFileOutcomeCallable GraceClient::getFileCallable(const GetFileRequest &request) const
{
auto task = std::make_shared<std::packaged_task<GetFileOutcome()>>(
[this, request]()
{
return this->getFile(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
GraceClient::UploadFileByOSSOutcome GraceClient::uploadFileByOSS(const UploadFileByOSSRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return UploadFileByOSSOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return UploadFileByOSSOutcome(UploadFileByOSSResult(outcome.result()));
else
return UploadFileByOSSOutcome(outcome.error());
}
void GraceClient::uploadFileByOSSAsync(const UploadFileByOSSRequest& request, const UploadFileByOSSAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, uploadFileByOSS(request), context);
};
asyncExecute(new Runnable(fn));
}
GraceClient::UploadFileByOSSOutcomeCallable GraceClient::uploadFileByOSSCallable(const UploadFileByOSSRequest &request) const
{
auto task = std::make_shared<std::packaged_task<UploadFileByOSSOutcome()>>(
[this, request]()
{
return this->uploadFileByOSS(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
GraceClient::UploadFileByURLOutcome GraceClient::uploadFileByURL(const UploadFileByURLRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return UploadFileByURLOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return UploadFileByURLOutcome(UploadFileByURLResult(outcome.result()));
else
return UploadFileByURLOutcome(outcome.error());
}
void GraceClient::uploadFileByURLAsync(const UploadFileByURLRequest& request, const UploadFileByURLAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, uploadFileByURL(request), context);
};
asyncExecute(new Runnable(fn));
}
GraceClient::UploadFileByURLOutcomeCallable GraceClient::uploadFileByURLCallable(const UploadFileByURLRequest &request) const
{
auto task = std::make_shared<std::packaged_task<UploadFileByURLOutcome()>>(
[this, request]()
{
return this->uploadFileByURL(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}

View File

@@ -0,0 +1,55 @@
/*
* 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/grace/model/AnalyzeFileRequest.h>
using AlibabaCloud::Grace::Model::AnalyzeFileRequest;
AnalyzeFileRequest::AnalyzeFileRequest()
: RoaServiceRequest("grace", "2022-06-06") {
setResourcePath("/AnalyzeFile"};
setMethod(HttpRequest::Method::Post);
}
AnalyzeFileRequest::~AnalyzeFileRequest() {}
bool AnalyzeFileRequest::getKeepUnreachableObjects() const {
return keepUnreachableObjects_;
}
void AnalyzeFileRequest::setKeepUnreachableObjects(bool keepUnreachableObjects) {
keepUnreachableObjects_ = keepUnreachableObjects;
setParameter(std::string("keepUnreachableObjects"), keepUnreachableObjects ? "true" : "false");
}
std::string AnalyzeFileRequest::getToken() const {
return token_;
}
void AnalyzeFileRequest::setToken(const std::string &token) {
token_ = token;
setParameter(std::string("token"), token);
}
std::string AnalyzeFileRequest::getName() const {
return name_;
}
void AnalyzeFileRequest::setName(const std::string &name) {
name_ = name;
setParameter(std::string("name"), name);
}

View File

@@ -0,0 +1,58 @@
/*
* 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/grace/model/AnalyzeFileResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Grace;
using namespace AlibabaCloud::Grace::Model;
AnalyzeFileResult::AnalyzeFileResult() :
ServiceResult()
{}
AnalyzeFileResult::AnalyzeFileResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
AnalyzeFileResult::~AnalyzeFileResult()
{}
void AnalyzeFileResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["requestId"].isNull())
requestId_ = value["requestId"].asString();
if(!value["fileName"].isNull())
fileName_ = value["fileName"].asString();
}
std::string AnalyzeFileResult::getRequestId()const
{
return requestId_;
}
std::string AnalyzeFileResult::getFileName()const
{
return fileName_;
}

View File

@@ -0,0 +1,46 @@
/*
* 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/grace/model/GetFileRequest.h>
using AlibabaCloud::Grace::Model::GetFileRequest;
GetFileRequest::GetFileRequest()
: RoaServiceRequest("grace", "2022-06-06") {
setResourcePath("/GetFile"};
setMethod(HttpRequest::Method::Get);
}
GetFileRequest::~GetFileRequest() {}
std::string GetFileRequest::getToken() const {
return token_;
}
void GetFileRequest::setToken(const std::string &token) {
token_ = token;
setParameter(std::string("token"), token);
}
std::string GetFileRequest::getName() const {
return name_;
}
void GetFileRequest::setName(const std::string &name) {
name_ = name;
setParameter(std::string("name"), name);
}

View File

@@ -0,0 +1,129 @@
/*
* 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/grace/model/GetFileResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Grace;
using namespace AlibabaCloud::Grace::Model;
GetFileResult::GetFileResult() :
ServiceResult()
{}
GetFileResult::GetFileResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
GetFileResult::~GetFileResult()
{}
void GetFileResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto analyzeProgressNode = value["analyzeProgress"];
if(!analyzeProgressNode["message"].isNull())
analyzeProgress_.message = analyzeProgressNode["message"].asString();
if(!analyzeProgressNode["percent"].isNull())
analyzeProgress_.percent = analyzeProgressNode["percent"].asString();
if(!analyzeProgressNode["state"].isNull())
analyzeProgress_.state = analyzeProgressNode["state"].asString();
auto transferProgressNode = value["transferProgress"];
if(!transferProgressNode["totalSize"].isNull())
transferProgress_.totalSize = std::stol(transferProgressNode["totalSize"].asString());
if(!transferProgressNode["transferredSize"].isNull())
transferProgress_.transferredSize = std::stol(transferProgressNode["transferredSize"].asString());
if(!value["type"].isNull())
type_ = value["type"].asString();
if(!value["size"].isNull())
size_ = std::stol(value["size"].asString());
if(!value["creationTime"].isNull())
creationTime_ = std::stol(value["creationTime"].asString());
if(!value["displayName"].isNull())
displayName_ = value["displayName"].asString();
if(!value["labels"].isNull())
labels_ = value["labels"].asString();
if(!value["shared"].isNull())
shared_ = value["shared"].asString() == "true";
if(!value["transferState"].isNull())
transferState_ = value["transferState"].asString();
if(!value["name"].isNull())
name_ = value["name"].asString();
if(!value["requestId"].isNull())
requestId_ = value["requestId"].asString();
}
std::string GetFileResult::getType()const
{
return type_;
}
std::string GetFileResult::getRequestId()const
{
return requestId_;
}
long GetFileResult::getSize()const
{
return size_;
}
GetFileResult::AnalyzeProgress GetFileResult::getAnalyzeProgress()const
{
return analyzeProgress_;
}
long GetFileResult::getCreationTime()const
{
return creationTime_;
}
std::string GetFileResult::getDisplayName()const
{
return displayName_;
}
std::string GetFileResult::getLabels()const
{
return labels_;
}
bool GetFileResult::getShared()const
{
return shared_;
}
std::string GetFileResult::getTransferState()const
{
return transferState_;
}
GetFileResult::TransferProgress GetFileResult::getTransferProgress()const
{
return transferProgress_;
}
std::string GetFileResult::getName()const
{
return name_;
}

View File

@@ -0,0 +1,73 @@
/*
* 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/grace/model/UploadFileByOSSRequest.h>
using AlibabaCloud::Grace::Model::UploadFileByOSSRequest;
UploadFileByOSSRequest::UploadFileByOSSRequest()
: RoaServiceRequest("grace", "2022-06-06") {
setResourcePath("/UploadFileByOSS"};
setMethod(HttpRequest::Method::Post);
}
UploadFileByOSSRequest::~UploadFileByOSSRequest() {}
std::string UploadFileByOSSRequest::getObjectName() const {
return objectName_;
}
void UploadFileByOSSRequest::setObjectName(const std::string &objectName) {
objectName_ = objectName;
setParameter(std::string("objectName"), objectName);
}
std::string UploadFileByOSSRequest::getType() const {
return type_;
}
void UploadFileByOSSRequest::setType(const std::string &type) {
type_ = type;
setParameter(std::string("type"), type);
}
std::string UploadFileByOSSRequest::getEndpoint() const {
return endpoint_;
}
void UploadFileByOSSRequest::setEndpoint(const std::string &endpoint) {
endpoint_ = endpoint;
setParameter(std::string("endpoint"), endpoint);
}
std::string UploadFileByOSSRequest::getBucketName() const {
return bucketName_;
}
void UploadFileByOSSRequest::setBucketName(const std::string &bucketName) {
bucketName_ = bucketName;
setParameter(std::string("bucketName"), bucketName);
}
std::string UploadFileByOSSRequest::getDisplayName() const {
return displayName_;
}
void UploadFileByOSSRequest::setDisplayName(const std::string &displayName) {
displayName_ = displayName;
setParameter(std::string("displayName"), displayName);
}

View File

@@ -0,0 +1,58 @@
/*
* 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/grace/model/UploadFileByOSSResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Grace;
using namespace AlibabaCloud::Grace::Model;
UploadFileByOSSResult::UploadFileByOSSResult() :
ServiceResult()
{}
UploadFileByOSSResult::UploadFileByOSSResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
UploadFileByOSSResult::~UploadFileByOSSResult()
{}
void UploadFileByOSSResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["name"].isNull())
name_ = value["name"].asString();
if(!value["requestId"].isNull())
requestId_ = value["requestId"].asString();
}
std::string UploadFileByOSSResult::getRequestId()const
{
return requestId_;
}
std::string UploadFileByOSSResult::getName()const
{
return name_;
}

View File

@@ -0,0 +1,55 @@
/*
* 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/grace/model/UploadFileByURLRequest.h>
using AlibabaCloud::Grace::Model::UploadFileByURLRequest;
UploadFileByURLRequest::UploadFileByURLRequest()
: RoaServiceRequest("grace", "2022-06-06") {
setResourcePath("/UploadFileByURL"};
setMethod(HttpRequest::Method::Post);
}
UploadFileByURLRequest::~UploadFileByURLRequest() {}
std::string UploadFileByURLRequest::getType() const {
return type_;
}
void UploadFileByURLRequest::setType(const std::string &type) {
type_ = type;
setParameter(std::string("type"), type);
}
std::string UploadFileByURLRequest::getUrl() const {
return url_;
}
void UploadFileByURLRequest::setUrl(const std::string &url) {
url_ = url;
setParameter(std::string("url"), url);
}
std::string UploadFileByURLRequest::getDisplayName() const {
return displayName_;
}
void UploadFileByURLRequest::setDisplayName(const std::string &displayName) {
displayName_ = displayName;
setParameter(std::string("displayName"), displayName);
}

View File

@@ -0,0 +1,58 @@
/*
* 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/grace/model/UploadFileByURLResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Grace;
using namespace AlibabaCloud::Grace::Model;
UploadFileByURLResult::UploadFileByURLResult() :
ServiceResult()
{}
UploadFileByURLResult::UploadFileByURLResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
UploadFileByURLResult::~UploadFileByURLResult()
{}
void UploadFileByURLResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["requestId"].isNull())
requestId_ = value["requestId"].asString();
if(!value["name"].isNull())
name_ = value["name"].asString();
}
std::string UploadFileByURLResult::getRequestId()const
{
return requestId_;
}
std::string UploadFileByURLResult::getName()const
{
return name_;
}