STS SDK Auto Released By shenshi,Version:1.34.19

Signed-off-by: haowei.yao <haowei.yao@alibaba-inc.com>
This commit is contained in:
haowei.yao
2019-03-14 13:35:32 +08:00
parent 26d4cdb3b5
commit a59527266e
19 changed files with 1045 additions and 2 deletions

View File

@@ -1,3 +1,6 @@
2019-03-14 Version: 1.34.19
1, Update Dependency
2019-03-14 Version: 1.34.18
1, Update Dependency

View File

@@ -95,4 +95,5 @@ add_subdirectory(xspace)
add_subdirectory(jarvis-public)
add_subdirectory(cbn)
add_subdirectory(emr)
add_subdirectory(ram)
add_subdirectory(ram)
add_subdirectory(sts)

View File

@@ -1 +1 @@
1.34.18
1.34.19

94
sts/CMakeLists.txt Normal file
View File

@@ -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}
)

View File

@@ -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 <future>
#include <alibabacloud/core/AsyncCallerContext.h>
#include <alibabacloud/core/EndpointProvider.h>
#include <alibabacloud/core/RpcServiceClient.h>
#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<Error, Model::GetCallerIdentityResult> GetCallerIdentityOutcome;
typedef std::future<GetCallerIdentityOutcome> GetCallerIdentityOutcomeCallable;
typedef std::function<void(const StsClient*, const Model::GetCallerIdentityRequest&, const GetCallerIdentityOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetCallerIdentityAsyncHandler;
typedef Outcome<Error, Model::GenerateSessionAccessKeyResult> GenerateSessionAccessKeyOutcome;
typedef std::future<GenerateSessionAccessKeyOutcome> GenerateSessionAccessKeyOutcomeCallable;
typedef std::function<void(const StsClient*, const Model::GenerateSessionAccessKeyRequest&, const GenerateSessionAccessKeyOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GenerateSessionAccessKeyAsyncHandler;
typedef Outcome<Error, Model::AssumeRoleResult> AssumeRoleOutcome;
typedef std::future<AssumeRoleOutcome> AssumeRoleOutcomeCallable;
typedef std::function<void(const StsClient*, const Model::AssumeRoleRequest&, const AssumeRoleOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> AssumeRoleAsyncHandler;
StsClient(const Credentials &credentials, const ClientConfiguration &configuration);
StsClient(const std::shared_ptr<CredentialsProvider> &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<const AsyncCallerContext>& 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<const AsyncCallerContext>& 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<const AsyncCallerContext>& context = nullptr) const;
AssumeRoleOutcomeCallable assumeRoleCallable(const Model::AssumeRoleRequest& request) const;
private:
std::shared_ptr<EndpointProvider> endpointProvider_;
};
}
}
#endif // !ALIBABACLOUD_STS_STSCLIENT_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_STS_STSEXPORT_H_
#define ALIBABACLOUD_STS_STSEXPORT_H_
#include <alibabacloud/core/Global.h>
#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_

View File

@@ -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 <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/sts/StsExport.h>
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_

View File

@@ -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 <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/sts/StsExport.h>
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_

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_STS_MODEL_GENERATESESSIONACCESSKEYREQUEST_H_
#define ALIBABACLOUD_STS_MODEL_GENERATESESSIONACCESSKEYREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/sts/StsExport.h>
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_

View File

@@ -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 <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/sts/StsExport.h>
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_

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_STS_MODEL_GETCALLERIDENTITYREQUEST_H_
#define ALIBABACLOUD_STS_MODEL_GETCALLERIDENTITYREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/sts/StsExport.h>
namespace AlibabaCloud
{
namespace Sts
{
namespace Model
{
class ALIBABACLOUD_STS_EXPORT GetCallerIdentityRequest : public RpcServiceRequest
{
public:
GetCallerIdentityRequest();
~GetCallerIdentityRequest();
private:
};
}
}
}
#endif // !ALIBABACLOUD_STS_MODEL_GETCALLERIDENTITYREQUEST_H_

View File

@@ -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 <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/sts/StsExport.h>
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_

161
sts/src/StsClient.cc Normal file
View File

@@ -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 <alibabacloud/sts/StsClient.h>
#include <alibabacloud/core/SimpleCredentialsProvider.h>
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<SimpleCredentialsProvider>(credentials), configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "sts");
}
StsClient::StsClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "sts");
}
StsClient::StsClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
{
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "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<const AsyncCallerContext>& 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<std::packaged_task<GetCallerIdentityOutcome()>>(
[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<const AsyncCallerContext>& 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<std::packaged_task<GenerateSessionAccessKeyOutcome()>>(
[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<const AsyncCallerContext>& 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<std::packaged_task<AssumeRoleOutcome()>>(
[this, request]()
{
return this->assumeRole(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}

View File

@@ -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 <alibabacloud/sts/model/AssumeRoleRequest.h>
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);
}

View File

@@ -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 <alibabacloud/sts/model/AssumeRoleResult.h>
#include <json/json.h>
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_;
}

View File

@@ -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 <alibabacloud/sts/model/GenerateSessionAccessKeyRequest.h>
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));
}

View File

@@ -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 <alibabacloud/sts/model/GenerateSessionAccessKeyResult.h>
#include <json/json.h>
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_;
}

View File

@@ -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 <alibabacloud/sts/model/GetCallerIdentityRequest.h>
using AlibabaCloud::Sts::Model::GetCallerIdentityRequest;
GetCallerIdentityRequest::GetCallerIdentityRequest() :
RpcServiceRequest("sts", "2015-04-01", "GetCallerIdentity")
{}
GetCallerIdentityRequest::~GetCallerIdentityRequest()
{}

View File

@@ -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 <alibabacloud/sts/model/GetCallerIdentityResult.h>
#include <json/json.h>
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_;
}