diff --git a/CHANGELOG b/CHANGELOG index ad7a8d680..82d61f10e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2019-03-14 Version: 1.34.19 +1, Update Dependency + 2019-03-14 Version: 1.34.18 1, Update Dependency diff --git a/CMakeLists.txt b/CMakeLists.txt index a369517cf..f0ab4e927 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,4 +95,5 @@ add_subdirectory(xspace) add_subdirectory(jarvis-public) add_subdirectory(cbn) add_subdirectory(emr) -add_subdirectory(ram) \ No newline at end of file +add_subdirectory(ram) +add_subdirectory(sts) \ No newline at end of file diff --git a/VERSION b/VERSION index 8ea9bbbf3..ccdfb8596 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.34.18 \ No newline at end of file +1.34.19 \ No newline at end of file diff --git a/sts/CMakeLists.txt b/sts/CMakeLists.txt new file mode 100644 index 000000000..0150b7e9c --- /dev/null +++ b/sts/CMakeLists.txt @@ -0,0 +1,94 @@ +# +# 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(sts_public_header + include/alibabacloud/sts/StsClient.h + include/alibabacloud/sts/StsExport.h ) + +set(sts_public_header_model + include/alibabacloud/sts/model/GetCallerIdentityRequest.h + include/alibabacloud/sts/model/GetCallerIdentityResult.h + include/alibabacloud/sts/model/GenerateSessionAccessKeyRequest.h + include/alibabacloud/sts/model/GenerateSessionAccessKeyResult.h + include/alibabacloud/sts/model/AssumeRoleRequest.h + include/alibabacloud/sts/model/AssumeRoleResult.h ) + +set(sts_src + src/StsClient.cc + src/model/GetCallerIdentityRequest.cc + src/model/GetCallerIdentityResult.cc + src/model/GenerateSessionAccessKeyRequest.cc + src/model/GenerateSessionAccessKeyResult.cc + src/model/AssumeRoleRequest.cc + src/model/AssumeRoleResult.cc ) + +add_library(sts ${LIB_TYPE} + ${sts_public_header} + ${sts_public_header_model} + ${sts_src}) + +set_target_properties(sts + 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}sts + ) + +if(${LIB_TYPE} STREQUAL "SHARED") + set_target_properties(sts + PROPERTIES + DEFINE_SYMBOL ALIBABACLOUD_STS_LIBRARY) +endif() + +target_include_directories(sts + PRIVATE include + ${CMAKE_SOURCE_DIR}/core/include + ) +target_link_libraries(sts + core) + +if(CMAKE_HOST_WIN32) + ExternalProject_Get_Property(jsoncpp INSTALL_DIR) + set(jsoncpp_install_dir ${INSTALL_DIR}) + add_dependencies(sts + jsoncpp) + target_include_directories(sts + PRIVATE ${jsoncpp_install_dir}/include) + target_link_libraries(sts + ${jsoncpp_install_dir}/lib/jsoncpp.lib) + set_target_properties(sts + PROPERTIES + COMPILE_OPTIONS "/bigobj") +else() + target_include_directories(sts + PRIVATE /usr/include/jsoncpp) + target_link_libraries(sts + jsoncpp) +endif() + +install(FILES ${sts_public_header} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/sts) +install(FILES ${sts_public_header_model} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/sts/model) +install(TARGETS sts + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) \ No newline at end of file diff --git a/sts/include/alibabacloud/sts/StsClient.h b/sts/include/alibabacloud/sts/StsClient.h new file mode 100644 index 000000000..0d839f5c4 --- /dev/null +++ b/sts/include/alibabacloud/sts/StsClient.h @@ -0,0 +1,70 @@ +/* + * 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_STS_STSCLIENT_H_ +#define ALIBABACLOUD_STS_STSCLIENT_H_ + +#include +#include +#include +#include +#include "StsExport.h" +#include "model/GetCallerIdentityRequest.h" +#include "model/GetCallerIdentityResult.h" +#include "model/GenerateSessionAccessKeyRequest.h" +#include "model/GenerateSessionAccessKeyResult.h" +#include "model/AssumeRoleRequest.h" +#include "model/AssumeRoleResult.h" + + +namespace AlibabaCloud +{ + namespace Sts + { + class ALIBABACLOUD_STS_EXPORT StsClient : public RpcServiceClient + { + public: + typedef Outcome GetCallerIdentityOutcome; + typedef std::future GetCallerIdentityOutcomeCallable; + typedef std::function&)> GetCallerIdentityAsyncHandler; + typedef Outcome GenerateSessionAccessKeyOutcome; + typedef std::future GenerateSessionAccessKeyOutcomeCallable; + typedef std::function&)> GenerateSessionAccessKeyAsyncHandler; + typedef Outcome AssumeRoleOutcome; + typedef std::future AssumeRoleOutcomeCallable; + typedef std::function&)> AssumeRoleAsyncHandler; + + StsClient(const Credentials &credentials, const ClientConfiguration &configuration); + StsClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); + StsClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); + ~StsClient(); + GetCallerIdentityOutcome getCallerIdentity(const Model::GetCallerIdentityRequest &request)const; + void getCallerIdentityAsync(const Model::GetCallerIdentityRequest& request, const GetCallerIdentityAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + GetCallerIdentityOutcomeCallable getCallerIdentityCallable(const Model::GetCallerIdentityRequest& request) const; + GenerateSessionAccessKeyOutcome generateSessionAccessKey(const Model::GenerateSessionAccessKeyRequest &request)const; + void generateSessionAccessKeyAsync(const Model::GenerateSessionAccessKeyRequest& request, const GenerateSessionAccessKeyAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + GenerateSessionAccessKeyOutcomeCallable generateSessionAccessKeyCallable(const Model::GenerateSessionAccessKeyRequest& request) const; + AssumeRoleOutcome assumeRole(const Model::AssumeRoleRequest &request)const; + void assumeRoleAsync(const Model::AssumeRoleRequest& request, const AssumeRoleAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + AssumeRoleOutcomeCallable assumeRoleCallable(const Model::AssumeRoleRequest& request) const; + + private: + std::shared_ptr endpointProvider_; + }; + } +} + +#endif // !ALIBABACLOUD_STS_STSCLIENT_H_ diff --git a/sts/include/alibabacloud/sts/StsExport.h b/sts/include/alibabacloud/sts/StsExport.h new file mode 100644 index 000000000..0753ea4bc --- /dev/null +++ b/sts/include/alibabacloud/sts/StsExport.h @@ -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_STS_STSEXPORT_H_ +#define ALIBABACLOUD_STS_STSEXPORT_H_ + +#include + +#if defined(ALIBABACLOUD_SHARED) +# if defined(ALIBABACLOUD_STS_LIBRARY) +# define ALIBABACLOUD_STS_EXPORT ALIBABACLOUD_DECL_EXPORT +# else +# define ALIBABACLOUD_STS_EXPORT ALIBABACLOUD_DECL_IMPORT +# endif +#else +# define ALIBABACLOUD_STS_EXPORT +#endif + +#endif // !ALIBABACLOUD_STS_STSEXPORT_H_ \ No newline at end of file diff --git a/sts/include/alibabacloud/sts/model/AssumeRoleRequest.h b/sts/include/alibabacloud/sts/model/AssumeRoleRequest.h new file mode 100644 index 000000000..9cf6e6d83 --- /dev/null +++ b/sts/include/alibabacloud/sts/model/AssumeRoleRequest.h @@ -0,0 +1,57 @@ +/* + * 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_STS_MODEL_ASSUMEROLEREQUEST_H_ +#define ALIBABACLOUD_STS_MODEL_ASSUMEROLEREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Sts + { + namespace Model + { + class ALIBABACLOUD_STS_EXPORT AssumeRoleRequest : public RpcServiceRequest + { + + public: + AssumeRoleRequest(); + ~AssumeRoleRequest(); + + std::string getRoleArn()const; + void setRoleArn(const std::string& roleArn); + std::string getRoleSessionName()const; + void setRoleSessionName(const std::string& roleSessionName); + long getDurationSeconds()const; + void setDurationSeconds(long durationSeconds); + std::string getPolicy()const; + void setPolicy(const std::string& policy); + + private: + std::string roleArn_; + std::string roleSessionName_; + long durationSeconds_; + std::string policy_; + + }; + } + } +} +#endif // !ALIBABACLOUD_STS_MODEL_ASSUMEROLEREQUEST_H_ \ No newline at end of file diff --git a/sts/include/alibabacloud/sts/model/AssumeRoleResult.h b/sts/include/alibabacloud/sts/model/AssumeRoleResult.h new file mode 100644 index 000000000..d2ba7f786 --- /dev/null +++ b/sts/include/alibabacloud/sts/model/AssumeRoleResult.h @@ -0,0 +1,65 @@ +/* + * 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_STS_MODEL_ASSUMEROLERESULT_H_ +#define ALIBABACLOUD_STS_MODEL_ASSUMEROLERESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Sts + { + namespace Model + { + class ALIBABACLOUD_STS_EXPORT AssumeRoleResult : public ServiceResult + { + public: + struct Credentials + { + std::string securityToken; + std::string accessKeyId; + std::string accessKeySecret; + std::string expiration; + }; + struct AssumedRoleUser + { + std::string arn; + std::string assumedRoleId; + }; + + + AssumeRoleResult(); + explicit AssumeRoleResult(const std::string &payload); + ~AssumeRoleResult(); + AssumedRoleUser getAssumedRoleUser()const; + Credentials getCredentials()const; + + protected: + void parse(const std::string &payload); + private: + AssumedRoleUser assumedRoleUser_; + Credentials credentials_; + + }; + } + } +} +#endif // !ALIBABACLOUD_STS_MODEL_ASSUMEROLERESULT_H_ \ No newline at end of file diff --git a/sts/include/alibabacloud/sts/model/GenerateSessionAccessKeyRequest.h b/sts/include/alibabacloud/sts/model/GenerateSessionAccessKeyRequest.h new file mode 100644 index 000000000..3b7732e70 --- /dev/null +++ b/sts/include/alibabacloud/sts/model/GenerateSessionAccessKeyRequest.h @@ -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_STS_MODEL_GENERATESESSIONACCESSKEYREQUEST_H_ +#define ALIBABACLOUD_STS_MODEL_GENERATESESSIONACCESSKEYREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Sts + { + namespace Model + { + class ALIBABACLOUD_STS_EXPORT GenerateSessionAccessKeyRequest : public RpcServiceRequest + { + + public: + GenerateSessionAccessKeyRequest(); + ~GenerateSessionAccessKeyRequest(); + + long getDurationSeconds()const; + void setDurationSeconds(long durationSeconds); + + private: + long durationSeconds_; + + }; + } + } +} +#endif // !ALIBABACLOUD_STS_MODEL_GENERATESESSIONACCESSKEYREQUEST_H_ \ No newline at end of file diff --git a/sts/include/alibabacloud/sts/model/GenerateSessionAccessKeyResult.h b/sts/include/alibabacloud/sts/model/GenerateSessionAccessKeyResult.h new file mode 100644 index 000000000..61395ecf5 --- /dev/null +++ b/sts/include/alibabacloud/sts/model/GenerateSessionAccessKeyResult.h @@ -0,0 +1,57 @@ +/* + * 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_STS_MODEL_GENERATESESSIONACCESSKEYRESULT_H_ +#define ALIBABACLOUD_STS_MODEL_GENERATESESSIONACCESSKEYRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Sts + { + namespace Model + { + class ALIBABACLOUD_STS_EXPORT GenerateSessionAccessKeyResult : public ServiceResult + { + public: + struct SessionAccessKey + { + std::string sessionAccessKeyId; + std::string expiration; + std::string sessionAccessKeySecret; + }; + + + GenerateSessionAccessKeyResult(); + explicit GenerateSessionAccessKeyResult(const std::string &payload); + ~GenerateSessionAccessKeyResult(); + SessionAccessKey getSessionAccessKey()const; + + protected: + void parse(const std::string &payload); + private: + SessionAccessKey sessionAccessKey_; + + }; + } + } +} +#endif // !ALIBABACLOUD_STS_MODEL_GENERATESESSIONACCESSKEYRESULT_H_ \ No newline at end of file diff --git a/sts/include/alibabacloud/sts/model/GetCallerIdentityRequest.h b/sts/include/alibabacloud/sts/model/GetCallerIdentityRequest.h new file mode 100644 index 000000000..738dd6bae --- /dev/null +++ b/sts/include/alibabacloud/sts/model/GetCallerIdentityRequest.h @@ -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_STS_MODEL_GETCALLERIDENTITYREQUEST_H_ +#define ALIBABACLOUD_STS_MODEL_GETCALLERIDENTITYREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Sts + { + namespace Model + { + class ALIBABACLOUD_STS_EXPORT GetCallerIdentityRequest : public RpcServiceRequest + { + + public: + GetCallerIdentityRequest(); + ~GetCallerIdentityRequest(); + + + private: + + }; + } + } +} +#endif // !ALIBABACLOUD_STS_MODEL_GETCALLERIDENTITYREQUEST_H_ \ No newline at end of file diff --git a/sts/include/alibabacloud/sts/model/GetCallerIdentityResult.h b/sts/include/alibabacloud/sts/model/GetCallerIdentityResult.h new file mode 100644 index 000000000..21be647fa --- /dev/null +++ b/sts/include/alibabacloud/sts/model/GetCallerIdentityResult.h @@ -0,0 +1,61 @@ +/* + * 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_STS_MODEL_GETCALLERIDENTITYRESULT_H_ +#define ALIBABACLOUD_STS_MODEL_GETCALLERIDENTITYRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Sts + { + namespace Model + { + class ALIBABACLOUD_STS_EXPORT GetCallerIdentityResult : public ServiceResult + { + public: + + + GetCallerIdentityResult(); + explicit GetCallerIdentityResult(const std::string &payload); + ~GetCallerIdentityResult(); + std::string getIdentityType()const; + std::string getAccountId()const; + std::string getPrincipalId()const; + std::string getUserId()const; + std::string getArn()const; + std::string getRoleId()const; + + protected: + void parse(const std::string &payload); + private: + std::string identityType_; + std::string accountId_; + std::string principalId_; + std::string userId_; + std::string arn_; + std::string roleId_; + + }; + } + } +} +#endif // !ALIBABACLOUD_STS_MODEL_GETCALLERIDENTITYRESULT_H_ \ No newline at end of file diff --git a/sts/src/StsClient.cc b/sts/src/StsClient.cc new file mode 100644 index 000000000..c2b482062 --- /dev/null +++ b/sts/src/StsClient.cc @@ -0,0 +1,161 @@ +/* + * 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 +#include + +using namespace AlibabaCloud; +using namespace AlibabaCloud::Location; +using namespace AlibabaCloud::Sts; +using namespace AlibabaCloud::Sts::Model; + +namespace +{ + const std::string SERVICE_NAME = "Sts"; +} + +StsClient::StsClient(const Credentials &credentials, const ClientConfiguration &configuration) : + RpcServiceClient(SERVICE_NAME, std::make_shared(credentials), configuration) +{ + auto locationClient = std::make_shared(credentials, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "sts"); +} + +StsClient::StsClient(const std::shared_ptr& credentialsProvider, const ClientConfiguration & configuration) : + RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) +{ + auto locationClient = std::make_shared(credentialsProvider, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "sts"); +} + +StsClient::StsClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) : + RpcServiceClient(SERVICE_NAME, std::make_shared(accessKeyId, accessKeySecret), configuration) +{ + auto locationClient = std::make_shared(accessKeyId, accessKeySecret, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "sts"); +} + +StsClient::~StsClient() +{} + +StsClient::GetCallerIdentityOutcome StsClient::getCallerIdentity(const GetCallerIdentityRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return GetCallerIdentityOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return GetCallerIdentityOutcome(GetCallerIdentityResult(outcome.result())); + else + return GetCallerIdentityOutcome(outcome.error()); +} + +void StsClient::getCallerIdentityAsync(const GetCallerIdentityRequest& request, const GetCallerIdentityAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, getCallerIdentity(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +StsClient::GetCallerIdentityOutcomeCallable StsClient::getCallerIdentityCallable(const GetCallerIdentityRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->getCallerIdentity(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + +StsClient::GenerateSessionAccessKeyOutcome StsClient::generateSessionAccessKey(const GenerateSessionAccessKeyRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return GenerateSessionAccessKeyOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return GenerateSessionAccessKeyOutcome(GenerateSessionAccessKeyResult(outcome.result())); + else + return GenerateSessionAccessKeyOutcome(outcome.error()); +} + +void StsClient::generateSessionAccessKeyAsync(const GenerateSessionAccessKeyRequest& request, const GenerateSessionAccessKeyAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, generateSessionAccessKey(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +StsClient::GenerateSessionAccessKeyOutcomeCallable StsClient::generateSessionAccessKeyCallable(const GenerateSessionAccessKeyRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->generateSessionAccessKey(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + +StsClient::AssumeRoleOutcome StsClient::assumeRole(const AssumeRoleRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return AssumeRoleOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return AssumeRoleOutcome(AssumeRoleResult(outcome.result())); + else + return AssumeRoleOutcome(outcome.error()); +} + +void StsClient::assumeRoleAsync(const AssumeRoleRequest& request, const AssumeRoleAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, assumeRole(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +StsClient::AssumeRoleOutcomeCallable StsClient::assumeRoleCallable(const AssumeRoleRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->assumeRole(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/sts/src/model/AssumeRoleRequest.cc b/sts/src/model/AssumeRoleRequest.cc new file mode 100644 index 000000000..b0a300563 --- /dev/null +++ b/sts/src/model/AssumeRoleRequest.cc @@ -0,0 +1,71 @@ +/* + * 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 + +using AlibabaCloud::Sts::Model::AssumeRoleRequest; + +AssumeRoleRequest::AssumeRoleRequest() : + RpcServiceRequest("sts", "2015-04-01", "AssumeRole") +{} + +AssumeRoleRequest::~AssumeRoleRequest() +{} + +std::string AssumeRoleRequest::getRoleArn()const +{ + return roleArn_; +} + +void AssumeRoleRequest::setRoleArn(const std::string& roleArn) +{ + roleArn_ = roleArn; + setParameter("RoleArn", roleArn); +} + +std::string AssumeRoleRequest::getRoleSessionName()const +{ + return roleSessionName_; +} + +void AssumeRoleRequest::setRoleSessionName(const std::string& roleSessionName) +{ + roleSessionName_ = roleSessionName; + setParameter("RoleSessionName", roleSessionName); +} + +long AssumeRoleRequest::getDurationSeconds()const +{ + return durationSeconds_; +} + +void AssumeRoleRequest::setDurationSeconds(long durationSeconds) +{ + durationSeconds_ = durationSeconds; + setParameter("DurationSeconds", std::to_string(durationSeconds)); +} + +std::string AssumeRoleRequest::getPolicy()const +{ + return policy_; +} + +void AssumeRoleRequest::setPolicy(const std::string& policy) +{ + policy_ = policy; + setParameter("Policy", policy); +} + diff --git a/sts/src/model/AssumeRoleResult.cc b/sts/src/model/AssumeRoleResult.cc new file mode 100644 index 000000000..5fd3288b0 --- /dev/null +++ b/sts/src/model/AssumeRoleResult.cc @@ -0,0 +1,69 @@ +/* + * 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 +#include + +using namespace AlibabaCloud::Sts; +using namespace AlibabaCloud::Sts::Model; + +AssumeRoleResult::AssumeRoleResult() : + ServiceResult() +{} + +AssumeRoleResult::AssumeRoleResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +AssumeRoleResult::~AssumeRoleResult() +{} + +void AssumeRoleResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + + setRequestId(value["RequestId"].asString()); + auto credentialsNode = value["Credentials"]; + if(!credentialsNode["SecurityToken"].isNull()) + credentials_.securityToken = credentialsNode["SecurityToken"].asString(); + if(!credentialsNode["AccessKeySecret"].isNull()) + credentials_.accessKeySecret = credentialsNode["AccessKeySecret"].asString(); + if(!credentialsNode["AccessKeyId"].isNull()) + credentials_.accessKeyId = credentialsNode["AccessKeyId"].asString(); + if(!credentialsNode["Expiration"].isNull()) + credentials_.expiration = credentialsNode["Expiration"].asString(); + auto assumedRoleUserNode = value["AssumedRoleUser"]; + if(!assumedRoleUserNode["Arn"].isNull()) + assumedRoleUser_.arn = assumedRoleUserNode["Arn"].asString(); + if(!assumedRoleUserNode["AssumedRoleId"].isNull()) + assumedRoleUser_.assumedRoleId = assumedRoleUserNode["AssumedRoleId"].asString(); + +} + +AssumeRoleResult::AssumedRoleUser AssumeRoleResult::getAssumedRoleUser()const +{ + return assumedRoleUser_; +} + +AssumeRoleResult::Credentials AssumeRoleResult::getCredentials()const +{ + return credentials_; +} + diff --git a/sts/src/model/GenerateSessionAccessKeyRequest.cc b/sts/src/model/GenerateSessionAccessKeyRequest.cc new file mode 100644 index 000000000..fbf913f9d --- /dev/null +++ b/sts/src/model/GenerateSessionAccessKeyRequest.cc @@ -0,0 +1,38 @@ +/* + * 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 + +using AlibabaCloud::Sts::Model::GenerateSessionAccessKeyRequest; + +GenerateSessionAccessKeyRequest::GenerateSessionAccessKeyRequest() : + RpcServiceRequest("sts", "2015-04-01", "GenerateSessionAccessKey") +{} + +GenerateSessionAccessKeyRequest::~GenerateSessionAccessKeyRequest() +{} + +long GenerateSessionAccessKeyRequest::getDurationSeconds()const +{ + return durationSeconds_; +} + +void GenerateSessionAccessKeyRequest::setDurationSeconds(long durationSeconds) +{ + durationSeconds_ = durationSeconds; + setParameter("DurationSeconds", std::to_string(durationSeconds)); +} + diff --git a/sts/src/model/GenerateSessionAccessKeyResult.cc b/sts/src/model/GenerateSessionAccessKeyResult.cc new file mode 100644 index 000000000..95f5ab9fc --- /dev/null +++ b/sts/src/model/GenerateSessionAccessKeyResult.cc @@ -0,0 +1,57 @@ +/* + * 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 +#include + +using namespace AlibabaCloud::Sts; +using namespace AlibabaCloud::Sts::Model; + +GenerateSessionAccessKeyResult::GenerateSessionAccessKeyResult() : + ServiceResult() +{} + +GenerateSessionAccessKeyResult::GenerateSessionAccessKeyResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +GenerateSessionAccessKeyResult::~GenerateSessionAccessKeyResult() +{} + +void GenerateSessionAccessKeyResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + + setRequestId(value["RequestId"].asString()); + auto sessionAccessKeyNode = value["SessionAccessKey"]; + if(!sessionAccessKeyNode["SessionAccessKeyId"].isNull()) + sessionAccessKey_.sessionAccessKeyId = sessionAccessKeyNode["SessionAccessKeyId"].asString(); + if(!sessionAccessKeyNode["SessionAccessKeySecret"].isNull()) + sessionAccessKey_.sessionAccessKeySecret = sessionAccessKeyNode["SessionAccessKeySecret"].asString(); + if(!sessionAccessKeyNode["Expiration"].isNull()) + sessionAccessKey_.expiration = sessionAccessKeyNode["Expiration"].asString(); + +} + +GenerateSessionAccessKeyResult::SessionAccessKey GenerateSessionAccessKeyResult::getSessionAccessKey()const +{ + return sessionAccessKey_; +} + diff --git a/sts/src/model/GetCallerIdentityRequest.cc b/sts/src/model/GetCallerIdentityRequest.cc new file mode 100644 index 000000000..41f9a93bf --- /dev/null +++ b/sts/src/model/GetCallerIdentityRequest.cc @@ -0,0 +1,27 @@ +/* + * 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 + +using AlibabaCloud::Sts::Model::GetCallerIdentityRequest; + +GetCallerIdentityRequest::GetCallerIdentityRequest() : + RpcServiceRequest("sts", "2015-04-01", "GetCallerIdentity") +{} + +GetCallerIdentityRequest::~GetCallerIdentityRequest() +{} + diff --git a/sts/src/model/GetCallerIdentityResult.cc b/sts/src/model/GetCallerIdentityResult.cc new file mode 100644 index 000000000..7cd2a68e0 --- /dev/null +++ b/sts/src/model/GetCallerIdentityResult.cc @@ -0,0 +1,87 @@ +/* + * 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 +#include + +using namespace AlibabaCloud::Sts; +using namespace AlibabaCloud::Sts::Model; + +GetCallerIdentityResult::GetCallerIdentityResult() : + ServiceResult() +{} + +GetCallerIdentityResult::GetCallerIdentityResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +GetCallerIdentityResult::~GetCallerIdentityResult() +{} + +void GetCallerIdentityResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + + setRequestId(value["RequestId"].asString()); + if(!value["AccountId"].isNull()) + accountId_ = value["AccountId"].asString(); + if(!value["UserId"].isNull()) + userId_ = value["UserId"].asString(); + if(!value["RoleId"].isNull()) + roleId_ = value["RoleId"].asString(); + if(!value["Arn"].isNull()) + arn_ = value["Arn"].asString(); + if(!value["IdentityType"].isNull()) + identityType_ = value["IdentityType"].asString(); + if(!value["PrincipalId"].isNull()) + principalId_ = value["PrincipalId"].asString(); + +} + +std::string GetCallerIdentityResult::getIdentityType()const +{ + return identityType_; +} + +std::string GetCallerIdentityResult::getAccountId()const +{ + return accountId_; +} + +std::string GetCallerIdentityResult::getPrincipalId()const +{ + return principalId_; +} + +std::string GetCallerIdentityResult::getUserId()const +{ + return userId_; +} + +std::string GetCallerIdentityResult::getArn()const +{ + return arn_; +} + +std::string GetCallerIdentityResult::getRoleId()const +{ + return roleId_; +} +