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

View File

@@ -1 +1 @@
1.36.1700
1.36.1701

98
grace/CMakeLists.txt Normal file
View File

@@ -0,0 +1,98 @@
#
# 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.
#
set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include)
set(grace_public_header
include/alibabacloud/grace/GraceClient.h
include/alibabacloud/grace/GraceExport.h )
set(grace_public_header_model
include/alibabacloud/grace/model/AnalyzeFileRequest.h
include/alibabacloud/grace/model/AnalyzeFileResult.h
include/alibabacloud/grace/model/GetFileRequest.h
include/alibabacloud/grace/model/GetFileResult.h
include/alibabacloud/grace/model/UploadFileByOSSRequest.h
include/alibabacloud/grace/model/UploadFileByOSSResult.h
include/alibabacloud/grace/model/UploadFileByURLRequest.h
include/alibabacloud/grace/model/UploadFileByURLResult.h )
set(grace_src
src/GraceClient.cc
src/model/AnalyzeFileRequest.cc
src/model/AnalyzeFileResult.cc
src/model/GetFileRequest.cc
src/model/GetFileResult.cc
src/model/UploadFileByOSSRequest.cc
src/model/UploadFileByOSSResult.cc
src/model/UploadFileByURLRequest.cc
src/model/UploadFileByURLResult.cc )
add_library(grace ${LIB_TYPE}
${grace_public_header}
${grace_public_header_model}
${grace_src})
set_target_properties(grace
PROPERTIES
LINKER_LANGUAGE CXX
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}grace
)
if(${LIB_TYPE} STREQUAL "SHARED")
set_target_properties(grace
PROPERTIES
DEFINE_SYMBOL ALIBABACLOUD_GRACE_LIBRARY)
endif()
target_include_directories(grace
PRIVATE include
${CMAKE_SOURCE_DIR}/core/include
)
target_link_libraries(grace
core)
if(CMAKE_HOST_WIN32)
ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
set(jsoncpp_install_dir ${INSTALL_DIR})
add_dependencies(grace
jsoncpp)
target_include_directories(grace
PRIVATE ${jsoncpp_install_dir}/include)
target_link_libraries(grace
${jsoncpp_install_dir}/lib/jsoncpp.lib)
set_target_properties(grace
PROPERTIES
COMPILE_OPTIONS "/bigobj")
else()
target_include_directories(grace
PRIVATE /usr/include/jsoncpp)
target_link_libraries(grace
jsoncpp)
endif()
install(FILES ${grace_public_header}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/grace)
install(FILES ${grace_public_header_model}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/grace/model)
install(TARGETS grace
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

View File

@@ -0,0 +1,78 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_GRACECLIENT_H_
#define ALIBABACLOUD_GRACE_GRACECLIENT_H_
#include <future>
#include <alibabacloud/core/AsyncCallerContext.h>
#include <alibabacloud/core/EndpointProvider.h>
#include <alibabacloud/core/RoaServiceClient.h>
#include "GraceExport.h"
#include "model/AnalyzeFileRequest.h"
#include "model/AnalyzeFileResult.h"
#include "model/GetFileRequest.h"
#include "model/GetFileResult.h"
#include "model/UploadFileByOSSRequest.h"
#include "model/UploadFileByOSSResult.h"
#include "model/UploadFileByURLRequest.h"
#include "model/UploadFileByURLResult.h"
namespace AlibabaCloud
{
namespace Grace
{
class ALIBABACLOUD_GRACE_EXPORT GraceClient : public RoaServiceClient
{
public:
typedef Outcome<Error, Model::AnalyzeFileResult> AnalyzeFileOutcome;
typedef std::future<AnalyzeFileOutcome> AnalyzeFileOutcomeCallable;
typedef std::function<void(const GraceClient*, const Model::AnalyzeFileRequest&, const AnalyzeFileOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> AnalyzeFileAsyncHandler;
typedef Outcome<Error, Model::GetFileResult> GetFileOutcome;
typedef std::future<GetFileOutcome> GetFileOutcomeCallable;
typedef std::function<void(const GraceClient*, const Model::GetFileRequest&, const GetFileOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetFileAsyncHandler;
typedef Outcome<Error, Model::UploadFileByOSSResult> UploadFileByOSSOutcome;
typedef std::future<UploadFileByOSSOutcome> UploadFileByOSSOutcomeCallable;
typedef std::function<void(const GraceClient*, const Model::UploadFileByOSSRequest&, const UploadFileByOSSOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UploadFileByOSSAsyncHandler;
typedef Outcome<Error, Model::UploadFileByURLResult> UploadFileByURLOutcome;
typedef std::future<UploadFileByURLOutcome> UploadFileByURLOutcomeCallable;
typedef std::function<void(const GraceClient*, const Model::UploadFileByURLRequest&, const UploadFileByURLOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> UploadFileByURLAsyncHandler;
GraceClient(const Credentials &credentials, const ClientConfiguration &configuration);
GraceClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
GraceClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
~GraceClient();
AnalyzeFileOutcome analyzeFile(const Model::AnalyzeFileRequest &request)const;
void analyzeFileAsync(const Model::AnalyzeFileRequest& request, const AnalyzeFileAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
AnalyzeFileOutcomeCallable analyzeFileCallable(const Model::AnalyzeFileRequest& request) const;
GetFileOutcome getFile(const Model::GetFileRequest &request)const;
void getFileAsync(const Model::GetFileRequest& request, const GetFileAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetFileOutcomeCallable getFileCallable(const Model::GetFileRequest& request) const;
UploadFileByOSSOutcome uploadFileByOSS(const Model::UploadFileByOSSRequest &request)const;
void uploadFileByOSSAsync(const Model::UploadFileByOSSRequest& request, const UploadFileByOSSAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UploadFileByOSSOutcomeCallable uploadFileByOSSCallable(const Model::UploadFileByOSSRequest& request) const;
UploadFileByURLOutcome uploadFileByURL(const Model::UploadFileByURLRequest &request)const;
void uploadFileByURLAsync(const Model::UploadFileByURLRequest& request, const UploadFileByURLAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
UploadFileByURLOutcomeCallable uploadFileByURLCallable(const Model::UploadFileByURLRequest& request) const;
private:
std::shared_ptr<EndpointProvider> endpointProvider_;
};
}
}
#endif // !ALIBABACLOUD_GRACE_GRACECLIENT_H_

View File

@@ -0,0 +1,32 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_GRACEEXPORT_H_
#define ALIBABACLOUD_GRACE_GRACEEXPORT_H_
#include <alibabacloud/core/Global.h>
#if defined(ALIBABACLOUD_SHARED)
# if defined(ALIBABACLOUD_GRACE_LIBRARY)
# define ALIBABACLOUD_GRACE_EXPORT ALIBABACLOUD_DECL_EXPORT
# else
# define ALIBABACLOUD_GRACE_EXPORT ALIBABACLOUD_DECL_IMPORT
# endif
#else
# define ALIBABACLOUD_GRACE_EXPORT
#endif
#endif // !ALIBABACLOUD_GRACE_GRACEEXPORT_H_

View File

@@ -0,0 +1,48 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_MODEL_ANALYZEFILEREQUEST_H_
#define ALIBABACLOUD_GRACE_MODEL_ANALYZEFILEREQUEST_H_
#include <alibabacloud/grace/GraceExport.h>
#include <alibabacloud/core/RoaServiceRequest.h>
#include <string>
#include <vector>
#include <map>
namespace AlibabaCloud {
namespace Grace {
namespace Model {
class ALIBABACLOUD_GRACE_EXPORT AnalyzeFileRequest : public RoaServiceRequest {
public:
AnalyzeFileRequest();
~AnalyzeFileRequest();
bool getKeepUnreachableObjects() const;
void setKeepUnreachableObjects(bool keepUnreachableObjects);
std::string getToken() const;
void setToken(const std::string &token);
std::string getName() const;
void setName(const std::string &name);
private:
bool keepUnreachableObjects_;
std::string token_;
std::string name_;
};
} // namespace Model
} // namespace Grace
} // namespace AlibabaCloud
#endif // !ALIBABACLOUD_GRACE_MODEL_ANALYZEFILEREQUEST_H_

View File

@@ -0,0 +1,53 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_MODEL_ANALYZEFILERESULT_H_
#define ALIBABACLOUD_GRACE_MODEL_ANALYZEFILERESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/grace/GraceExport.h>
namespace AlibabaCloud
{
namespace Grace
{
namespace Model
{
class ALIBABACLOUD_GRACE_EXPORT AnalyzeFileResult : public ServiceResult
{
public:
AnalyzeFileResult();
explicit AnalyzeFileResult(const std::string &payload);
~AnalyzeFileResult();
std::string getRequestId()const;
std::string getFileName()const;
protected:
void parse(const std::string &payload);
private:
std::string requestId_;
std::string fileName_;
};
}
}
}
#endif // !ALIBABACLOUD_GRACE_MODEL_ANALYZEFILERESULT_H_

View File

@@ -0,0 +1,45 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_MODEL_GETFILEREQUEST_H_
#define ALIBABACLOUD_GRACE_MODEL_GETFILEREQUEST_H_
#include <alibabacloud/grace/GraceExport.h>
#include <alibabacloud/core/RoaServiceRequest.h>
#include <string>
#include <vector>
#include <map>
namespace AlibabaCloud {
namespace Grace {
namespace Model {
class ALIBABACLOUD_GRACE_EXPORT GetFileRequest : public RoaServiceRequest {
public:
GetFileRequest();
~GetFileRequest();
std::string getToken() const;
void setToken(const std::string &token);
std::string getName() const;
void setName(const std::string &name);
private:
std::string token_;
std::string name_;
};
} // namespace Model
} // namespace Grace
} // namespace AlibabaCloud
#endif // !ALIBABACLOUD_GRACE_MODEL_GETFILEREQUEST_H_

View File

@@ -0,0 +1,82 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_MODEL_GETFILERESULT_H_
#define ALIBABACLOUD_GRACE_MODEL_GETFILERESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/grace/GraceExport.h>
namespace AlibabaCloud
{
namespace Grace
{
namespace Model
{
class ALIBABACLOUD_GRACE_EXPORT GetFileResult : public ServiceResult
{
public:
struct AnalyzeProgress
{
std::string message;
double percent;
std::string state;
};
struct TransferProgress
{
long totalSize;
long transferredSize;
};
GetFileResult();
explicit GetFileResult(const std::string &payload);
~GetFileResult();
std::string getType()const;
std::string getRequestId()const;
long getSize()const;
AnalyzeProgress getAnalyzeProgress()const;
long getCreationTime()const;
std::string getDisplayName()const;
std::string getLabels()const;
bool getShared()const;
std::string getTransferState()const;
TransferProgress getTransferProgress()const;
std::string getName()const;
protected:
void parse(const std::string &payload);
private:
std::string type_;
std::string requestId_;
long size_;
AnalyzeProgress analyzeProgress_;
long creationTime_;
std::string displayName_;
std::string labels_;
bool shared_;
std::string transferState_;
TransferProgress transferProgress_;
std::string name_;
};
}
}
}
#endif // !ALIBABACLOUD_GRACE_MODEL_GETFILERESULT_H_

View File

@@ -0,0 +1,54 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYOSSREQUEST_H_
#define ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYOSSREQUEST_H_
#include <alibabacloud/grace/GraceExport.h>
#include <alibabacloud/core/RoaServiceRequest.h>
#include <string>
#include <vector>
#include <map>
namespace AlibabaCloud {
namespace Grace {
namespace Model {
class ALIBABACLOUD_GRACE_EXPORT UploadFileByOSSRequest : public RoaServiceRequest {
public:
UploadFileByOSSRequest();
~UploadFileByOSSRequest();
std::string getObjectName() const;
void setObjectName(const std::string &objectName);
std::string getType() const;
void setType(const std::string &type);
std::string getEndpoint() const;
void setEndpoint(const std::string &endpoint);
std::string getBucketName() const;
void setBucketName(const std::string &bucketName);
std::string getDisplayName() const;
void setDisplayName(const std::string &displayName);
private:
std::string objectName_;
std::string type_;
std::string endpoint_;
std::string bucketName_;
std::string displayName_;
};
} // namespace Model
} // namespace Grace
} // namespace AlibabaCloud
#endif // !ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYOSSREQUEST_H_

View File

@@ -0,0 +1,53 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYOSSRESULT_H_
#define ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYOSSRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/grace/GraceExport.h>
namespace AlibabaCloud
{
namespace Grace
{
namespace Model
{
class ALIBABACLOUD_GRACE_EXPORT UploadFileByOSSResult : public ServiceResult
{
public:
UploadFileByOSSResult();
explicit UploadFileByOSSResult(const std::string &payload);
~UploadFileByOSSResult();
std::string getRequestId()const;
std::string getName()const;
protected:
void parse(const std::string &payload);
private:
std::string requestId_;
std::string name_;
};
}
}
}
#endif // !ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYOSSRESULT_H_

View File

@@ -0,0 +1,48 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYURLREQUEST_H_
#define ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYURLREQUEST_H_
#include <alibabacloud/grace/GraceExport.h>
#include <alibabacloud/core/RoaServiceRequest.h>
#include <string>
#include <vector>
#include <map>
namespace AlibabaCloud {
namespace Grace {
namespace Model {
class ALIBABACLOUD_GRACE_EXPORT UploadFileByURLRequest : public RoaServiceRequest {
public:
UploadFileByURLRequest();
~UploadFileByURLRequest();
std::string getType() const;
void setType(const std::string &type);
std::string getUrl() const;
void setUrl(const std::string &url);
std::string getDisplayName() const;
void setDisplayName(const std::string &displayName);
private:
std::string type_;
std::string url_;
std::string displayName_;
};
} // namespace Model
} // namespace Grace
} // namespace AlibabaCloud
#endif // !ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYURLREQUEST_H_

View File

@@ -0,0 +1,53 @@
/*
* 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.
*/
#ifndef ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYURLRESULT_H_
#define ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYURLRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/grace/GraceExport.h>
namespace AlibabaCloud
{
namespace Grace
{
namespace Model
{
class ALIBABACLOUD_GRACE_EXPORT UploadFileByURLResult : public ServiceResult
{
public:
UploadFileByURLResult();
explicit UploadFileByURLResult(const std::string &payload);
~UploadFileByURLResult();
std::string getRequestId()const;
std::string getName()const;
protected:
void parse(const std::string &payload);
private:
std::string requestId_;
std::string name_;
};
}
}
}
#endif // !ALIBABACLOUD_GRACE_MODEL_UPLOADFILEBYURLRESULT_H_

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_;
}