|
|
@@ -1,57 +1,55 @@
|
|
|
/*
|
|
|
-* Copyright 1999-2019 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.
|
|
|
-*/
|
|
|
+ * Copyright 1999-2019 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/core/sts/StsClient.h>
|
|
|
-#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
|
|
#include <alibabacloud/core/EndpointProvider.h>
|
|
|
+#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
|
|
+#include <alibabacloud/core/sts/StsClient.h>
|
|
|
|
|
|
using namespace AlibabaCloud;
|
|
|
using namespace AlibabaCloud::Sts;
|
|
|
using namespace AlibabaCloud::Sts::Model;
|
|
|
|
|
|
namespace {
|
|
|
- const std::string SERVICE_NAME = "Sts";
|
|
|
- const std::string ENDPOINT = "sts.aliyuncs.com";
|
|
|
-}
|
|
|
+const std::string SERVICE_NAME = "Sts";
|
|
|
+const std::string ENDPOINT = "sts.aliyuncs.com";
|
|
|
+} // namespace
|
|
|
|
|
|
StsClient::StsClient(const Credentials &credentials,
|
|
|
- const ClientConfiguration &configuration) :
|
|
|
- RpcServiceClient(SERVICE_NAME,
|
|
|
- std::make_shared<SimpleCredentialsProvider>(credentials), configuration) {
|
|
|
-}
|
|
|
+ const ClientConfiguration &configuration)
|
|
|
+ : RpcServiceClient(SERVICE_NAME,
|
|
|
+ std::make_shared<SimpleCredentialsProvider>(credentials),
|
|
|
+ configuration) {}
|
|
|
|
|
|
StsClient::StsClient(
|
|
|
- const std::shared_ptr<CredentialsProvider>& credentialsProvider,
|
|
|
- const ClientConfiguration & configuration) :
|
|
|
- RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) {
|
|
|
-}
|
|
|
-
|
|
|
-StsClient::StsClient(const std::string & accessKeyId,
|
|
|
- const std::string & accessKeySecret,
|
|
|
- const ClientConfiguration & configuration) :
|
|
|
- RpcServiceClient(SERVICE_NAME,
|
|
|
- std::make_shared<SimpleCredentialsProvider>(accessKeyId,
|
|
|
- accessKeySecret), configuration) {
|
|
|
-}
|
|
|
-
|
|
|
-StsClient::~StsClient() {
|
|
|
-}
|
|
|
-
|
|
|
-StsClient::AssumeRoleOutcome StsClient::assumeRole(
|
|
|
- const Model::AssumeRoleRequest &request)const {
|
|
|
+ const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
|
|
+ const ClientConfiguration &configuration)
|
|
|
+ : RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) {}
|
|
|
+
|
|
|
+StsClient::StsClient(const std::string &accessKeyId,
|
|
|
+ const std::string &accessKeySecret,
|
|
|
+ const ClientConfiguration &configuration)
|
|
|
+ : RpcServiceClient(SERVICE_NAME,
|
|
|
+ std::make_shared<SimpleCredentialsProvider>(
|
|
|
+ accessKeyId, accessKeySecret),
|
|
|
+ configuration) {}
|
|
|
+
|
|
|
+StsClient::~StsClient() {}
|
|
|
+
|
|
|
+StsClient::AssumeRoleOutcome
|
|
|
+StsClient::assumeRole(const Model::AssumeRoleRequest &request) const {
|
|
|
auto outcome = makeRequest(ENDPOINT, request);
|
|
|
|
|
|
if (outcome.isSuccess())
|
|
|
@@ -60,9 +58,10 @@ StsClient::AssumeRoleOutcome StsClient::assumeRole(
|
|
|
return AssumeRoleOutcome(Error(outcome.error()));
|
|
|
}
|
|
|
|
|
|
-void StsClient::assumeRoleAsync(const Model::AssumeRoleRequest & request,
|
|
|
- const AssumeRoleAsyncHandler & handler,
|
|
|
- const std::shared_ptr<const AsyncCallerContext>& context) const {
|
|
|
+void StsClient::assumeRoleAsync(
|
|
|
+ const Model::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);
|
|
|
};
|
|
|
@@ -70,19 +69,17 @@ void StsClient::assumeRoleAsync(const Model::AssumeRoleRequest & request,
|
|
|
asyncExecute(new Runnable(fn));
|
|
|
}
|
|
|
|
|
|
-StsClient::AssumeRoleOutcomeCallable StsClient::assumeRoleCallable(
|
|
|
- const Model::AssumeRoleRequest & request) const {
|
|
|
+StsClient::AssumeRoleOutcomeCallable
|
|
|
+StsClient::assumeRoleCallable(const Model::AssumeRoleRequest &request) const {
|
|
|
auto task = std::make_shared<std::packaged_task<AssumeRoleOutcome()>>(
|
|
|
- [this, request]() {
|
|
|
- return this->assumeRole(request);
|
|
|
- });
|
|
|
+ [this, request]() { return this->assumeRole(request); });
|
|
|
|
|
|
asyncExecute(new Runnable([task]() { (*task)(); }));
|
|
|
return task->get_future();
|
|
|
}
|
|
|
|
|
|
-StsClient::GetCallerIdentityOutcome StsClient::getCallerIdentity(
|
|
|
- const GetCallerIdentityRequest &request) const {
|
|
|
+StsClient::GetCallerIdentityOutcome
|
|
|
+StsClient::getCallerIdentity(const GetCallerIdentityRequest &request) const {
|
|
|
auto outcome = makeRequest(ENDPOINT, request);
|
|
|
|
|
|
if (outcome.isSuccess())
|
|
|
@@ -91,9 +88,10 @@ StsClient::GetCallerIdentityOutcome StsClient::getCallerIdentity(
|
|
|
return GetCallerIdentityOutcome(Error(outcome.error()));
|
|
|
}
|
|
|
|
|
|
-void StsClient::getCallerIdentityAsync(const GetCallerIdentityRequest& request,
|
|
|
- const GetCallerIdentityAsyncHandler& handler,
|
|
|
- const std::shared_ptr<const AsyncCallerContext>& context) const {
|
|
|
+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);
|
|
|
};
|
|
|
@@ -103,11 +101,9 @@ void StsClient::getCallerIdentityAsync(const GetCallerIdentityRequest& request,
|
|
|
|
|
|
StsClient::GetCallerIdentityOutcomeCallable
|
|
|
StsClient::getCallerIdentityCallable(
|
|
|
- const GetCallerIdentityRequest &request) const {
|
|
|
+ const GetCallerIdentityRequest &request) const {
|
|
|
auto task = std::make_shared<std::packaged_task<GetCallerIdentityOutcome()>>(
|
|
|
- [this, request]() {
|
|
|
- return this->getCallerIdentity(request);
|
|
|
- });
|
|
|
+ [this, request]() { return this->getCallerIdentity(request); });
|
|
|
|
|
|
asyncExecute(new Runnable([task]() { (*task)(); }));
|
|
|
return task->get_future();
|