diff --git a/core/include/alibabacloud/core/AlibabaCloud.h b/core/include/alibabacloud/core/AlibabaCloud.h index 14b1c6f5a..5851f1a35 100644 --- a/core/include/alibabacloud/core/AlibabaCloud.h +++ b/core/include/alibabacloud/core/AlibabaCloud.h @@ -30,6 +30,6 @@ const long kDefaultReadTimeout = 10000; ALIBABACLOUD_CORE_EXPORT void InitializeSdk(); ALIBABACLOUD_CORE_EXPORT bool IsSdkInitialized(); ALIBABACLOUD_CORE_EXPORT void ShutdownSdk(); -} // namespace AlibabaCloud +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ALIBABACLOUD_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ALIBABACLOUD_H_ diff --git a/core/include/alibabacloud/core/AsyncCallerContext.h b/core/include/alibabacloud/core/AsyncCallerContext.h index f50c78bb6..e8303761e 100644 --- a/core/include/alibabacloud/core/AsyncCallerContext.h +++ b/core/include/alibabacloud/core/AsyncCallerContext.h @@ -17,21 +17,21 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_ -#include #include "CoreExport.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT AsyncCallerContext { - public: +public: AsyncCallerContext(); explicit AsyncCallerContext(const std::string &uuid); virtual ~AsyncCallerContext(); - std::string uuid()const; + std::string uuid() const; void setUuid(const std::string &uuid); - private: +private: std::string uuid_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_ diff --git a/core/include/alibabacloud/core/ClientConfiguration.h b/core/include/alibabacloud/core/ClientConfiguration.h index 5d2f66712..32cf67483 100644 --- a/core/include/alibabacloud/core/ClientConfiguration.h +++ b/core/include/alibabacloud/core/ClientConfiguration.h @@ -17,23 +17,23 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_ -#include -#include -#include "CredentialsProvider.h" #include "CoreExport.h" +#include "CredentialsProvider.h" #include "NetworkProxy.h" #include "Signer.h" +#include +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT ClientConfiguration { - public: +public: explicit ClientConfiguration(const std::string ®ionId = "cn-hangzhou", - const NetworkProxy &proxy = NetworkProxy()); + const NetworkProxy &proxy = NetworkProxy()); ~ClientConfiguration(); - std::string endpoint()const; - NetworkProxy proxy()const; - std::string regionId()const; + std::string endpoint() const; + NetworkProxy proxy() const; + std::string regionId() const; void setEndpoint(const std::string &endpoint); void setProxy(const NetworkProxy &proxy); void setRegionId(const std::string ®ionId); @@ -46,7 +46,7 @@ class ALIBABACLOUD_CORE_EXPORT ClientConfiguration { bool rejectUnauthorized() const; void setRejectUnauthorized(const bool rejectUnauthorized); - private: +private: std::string endpoint_; NetworkProxy proxy_; std::string regionId_; @@ -54,6 +54,6 @@ class ALIBABACLOUD_CORE_EXPORT ClientConfiguration { long readTimeout_; bool rejectUnauthorized_ = true; }; -} // namespace AlibabaCloud +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_ diff --git a/core/include/alibabacloud/core/CommonClient.h b/core/include/alibabacloud/core/CommonClient.h index b1b24f89a..a4ec09987 100644 --- a/core/include/alibabacloud/core/CommonClient.h +++ b/core/include/alibabacloud/core/CommonClient.h @@ -1,77 +1,81 @@ /* -* 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. + */ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONCLIENT_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONCLIENT_H_ +#include "AsyncCallerContext.h" +#include "ClientConfiguration.h" +#include "CommonRequest.h" +#include "CommonResponse.h" +#include "CoreClient.h" +#include "CoreExport.h" +#include "CredentialsProvider.h" #include #include #include -#include "AsyncCallerContext.h" -#include "ClientConfiguration.h" -#include "CoreExport.h" -#include "CoreClient.h" -#include "CommonRequest.h" -#include "CommonResponse.h" -#include "CredentialsProvider.h" namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT CommonClient : public CoreClient { - public: +public: typedef Outcome CommonResponseOutcome; typedef std::future CommonResponseOutcomeCallable; - typedef std::function&)> - CommonResponseAsyncHandler; + typedef std::function &)> + CommonResponseAsyncHandler; typedef Outcome JsonOutcome; CommonClient(const Credentials &credentials, - const ClientConfiguration &configuration); + const ClientConfiguration &configuration); CommonClient(const std::shared_ptr &credentialsProvider, - const ClientConfiguration &configuration); + const ClientConfiguration &configuration); CommonClient(const std::string &accessKeyId, - const std::string &accessKeySecret, - const ClientConfiguration &configuration); + const std::string &accessKeySecret, + const ClientConfiguration &configuration); ~CommonClient(); CommonResponseOutcome commonResponse(const CommonRequest &request) const; - void commonResponseAsync(const CommonRequest& request, - const CommonResponseAsyncHandler& handler, - const std::shared_ptr& context = nullptr) const; - CommonResponseOutcomeCallable commonResponseCallable( - const CommonRequest& request) const; + void commonResponseAsync( + const CommonRequest &request, const CommonResponseAsyncHandler &handler, + const std::shared_ptr &context = nullptr) const; + CommonResponseOutcomeCallable + commonResponseCallable(const CommonRequest &request) const; - protected: - HttpRequest buildHttpRequest(const std::string & endpoint, - const ServiceRequest & msg, HttpRequest::Method method) const override; - HttpRequest buildHttpRequest(const std::string & endpoint, - const CommonRequest &msg, HttpRequest::Method method) const; - HttpRequest buildRoaHttpRequest(const std::string & endpoint, - const CommonRequest &msg, HttpRequest::Method method) const; - HttpRequest buildRpcHttpRequest(const std::string & endpoint, - const CommonRequest &msg, HttpRequest::Method method) const; - JsonOutcome makeRequest(const std::string &endpoint, - const CommonRequest &msg, HttpRequest::Method method = - HttpRequest::Method::Get) const; +protected: + HttpRequest buildHttpRequest(const std::string &endpoint, + const ServiceRequest &msg, + HttpRequest::Method method) const override; + HttpRequest buildHttpRequest(const std::string &endpoint, + const CommonRequest &msg, + HttpRequest::Method method) const; + HttpRequest buildRoaHttpRequest(const std::string &endpoint, + const CommonRequest &msg, + HttpRequest::Method method) const; + HttpRequest buildRpcHttpRequest(const std::string &endpoint, + const CommonRequest &msg, + HttpRequest::Method method) const; + JsonOutcome + makeRequest(const std::string &endpoint, const CommonRequest &msg, + HttpRequest::Method method = HttpRequest::Method::Get) const; using CoreClient::asyncExecute; - private: +private: std::shared_ptr credentialsProvider_; std::shared_ptr signer_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONCLIENT_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONCLIENT_H_ diff --git a/core/include/alibabacloud/core/CommonRequest.h b/core/include/alibabacloud/core/CommonRequest.h index 5b141b135..e04bbaea0 100644 --- a/core/include/alibabacloud/core/CommonRequest.h +++ b/core/include/alibabacloud/core/CommonRequest.h @@ -1,34 +1,31 @@ /* -* 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. + */ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONREQUEST_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONREQUEST_H_ -#include #include "CoreExport.h" -#include "ServiceRequest.h" #include "HttpRequest.h" +#include "ServiceRequest.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT CommonRequest : public ServiceRequest { - public: - enum RequestPattern { - RpcPattern, - RoaPattern - }; +public: + enum RequestPattern { RpcPattern, RoaPattern }; explicit CommonRequest(RequestPattern pattern = RpcPattern); ~CommonRequest(); @@ -42,25 +39,25 @@ class ALIBABACLOUD_CORE_EXPORT CommonRequest : public ServiceRequest { using ServiceRequest::setContent; void setDomain(const std::string &domain); void setHeaderParameter(const ParameterNameType &name, - const ParameterValueType &value); + const ParameterValueType &value); void setHttpMethod(HttpRequest::Method method); void setQueryParameter(const ParameterNameType &name, - const ParameterValueType &value); + const ParameterValueType &value); using ServiceRequest::setResourcePath; void setRequestPattern(RequestPattern pattern); - using ServiceRequest::setVersion; using ServiceRequest::setScheme; + using ServiceRequest::setVersion; RequestPattern requestPattern() const; - protected: +protected: using ServiceRequest::product; - private: +private: std::string domain_; RequestPattern requestPattern_; ParameterCollection queryParams_; ParameterCollection headerParams_; HttpRequest::Method httpMethod_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONREQUEST_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONREQUEST_H_ diff --git a/core/include/alibabacloud/core/CommonResponse.h b/core/include/alibabacloud/core/CommonResponse.h index e95b4e39b..45a62a9e6 100644 --- a/core/include/alibabacloud/core/CommonResponse.h +++ b/core/include/alibabacloud/core/CommonResponse.h @@ -1,36 +1,36 @@ /* -* 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. + */ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONRESPONSE_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONRESPONSE_H_ -#include #include "CoreExport.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT CommonResponse { - public: +public: CommonResponse(); explicit CommonResponse(const std::string &payload); ~CommonResponse(); - std::string payload()const; + std::string payload() const; - private: +private: std::string payload_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONRESPONSE_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONRESPONSE_H_ diff --git a/core/include/alibabacloud/core/CoreClient.h b/core/include/alibabacloud/core/CoreClient.h index 93c2cfb2d..617027d64 100644 --- a/core/include/alibabacloud/core/CoreClient.h +++ b/core/include/alibabacloud/core/CoreClient.h @@ -17,43 +17,44 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_CORECLIENT_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_CORECLIENT_H_ -#include -#include -#include #include "ClientConfiguration.h" #include "CoreExport.h" #include "HttpClient.h" -#include "HttpResponse.h" #include "HttpRequest.h" +#include "HttpResponse.h" #include "Outcome.h" -#include "ServiceRequest.h" #include "Runnable.h" +#include "ServiceRequest.h" +#include +#include +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT CoreClient { - public: - CoreClient(const std::string & servicename, - const ClientConfiguration &configuration); +public: + CoreClient(const std::string &servicename, + const ClientConfiguration &configuration); virtual ~CoreClient(); ClientConfiguration configuration() const; std::string serviceName() const; - protected: - virtual HttpClient::HttpResponseOutcome AttemptRequest( - const std::string & endpoint, - const ServiceRequest &request, HttpRequest::Method method) const; - Error buildCoreError(const HttpResponse &response)const; - bool hasResponseError(const HttpResponse &response)const; - virtual HttpRequest buildHttpRequest(const std::string & endpoint, - const ServiceRequest &msg, HttpRequest::Method method) const = 0; - void asyncExecute(Runnable * r) const; +protected: + virtual HttpClient::HttpResponseOutcome + AttemptRequest(const std::string &endpoint, const ServiceRequest &request, + HttpRequest::Method method) const; + Error buildCoreError(const HttpResponse &response) const; + bool hasResponseError(const HttpResponse &response) const; + virtual HttpRequest buildHttpRequest(const std::string &endpoint, + const ServiceRequest &msg, + HttpRequest::Method method) const = 0; + void asyncExecute(Runnable *r) const; - private: +private: std::string serviceName_; ClientConfiguration configuration_; std::shared_ptr credentialsProvider_; HttpClient *httpClient_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CORECLIENT_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CORECLIENT_H_ diff --git a/core/include/alibabacloud/core/CoreExport.h b/core/include/alibabacloud/core/CoreExport.h index 72921893c..c1ca2f71c 100644 --- a/core/include/alibabacloud/core/CoreExport.h +++ b/core/include/alibabacloud/core/CoreExport.h @@ -20,13 +20,13 @@ #include "Global.h" #if defined(ALIBABACLOUD_SHARED) -# if defined(ALIBABACLOUD_CORE_LIBRARY) -# define ALIBABACLOUD_CORE_EXPORT ALIBABACLOUD_DECL_EXPORT -# else -# define ALIBABACLOUD_CORE_EXPORT ALIBABACLOUD_DECL_IMPORT -# endif +#if defined(ALIBABACLOUD_CORE_LIBRARY) +#define ALIBABACLOUD_CORE_EXPORT ALIBABACLOUD_DECL_EXPORT #else -# define ALIBABACLOUD_CORE_EXPORT +#define ALIBABACLOUD_CORE_EXPORT ALIBABACLOUD_DECL_IMPORT +#endif +#else +#define ALIBABACLOUD_CORE_EXPORT #endif -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COREEXPORT_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COREEXPORT_H_ diff --git a/core/include/alibabacloud/core/Credentials.h b/core/include/alibabacloud/core/Credentials.h index f5020cb97..a3320f47e 100644 --- a/core/include/alibabacloud/core/Credentials.h +++ b/core/include/alibabacloud/core/Credentials.h @@ -17,15 +17,15 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALS_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALS_H_ -#include #include "CoreExport.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT Credentials { - public: +public: Credentials(const std::string &accessKeyId, - const std::string &accessKeySecret, - const std::string &sessionToken = ""); + const std::string &accessKeySecret, + const std::string &sessionToken = ""); ~Credentials(); std::string accessKeyId() const; @@ -35,11 +35,11 @@ class ALIBABACLOUD_CORE_EXPORT Credentials { void setSessionToken(const std::string &sessionToken); std::string sessionToken() const; - private: +private: std::string accessKeyId_; std::string accessKeySecret_; std::string sessionToken_; }; -} // namespace AlibabaCloud +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALS_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALS_H_ diff --git a/core/include/alibabacloud/core/CredentialsProvider.h b/core/include/alibabacloud/core/CredentialsProvider.h index d03ff1c25..75a515b60 100644 --- a/core/include/alibabacloud/core/CredentialsProvider.h +++ b/core/include/alibabacloud/core/CredentialsProvider.h @@ -22,12 +22,12 @@ namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT CredentialsProvider { - public: +public: CredentialsProvider() = default; - virtual ~CredentialsProvider() = default; + virtual ~CredentialsProvider() = default; virtual Credentials getCredentials() = 0; - private: +private: }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALSPROVIDER_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALSPROVIDER_H_ diff --git a/core/include/alibabacloud/core/EndpointProvider.h b/core/include/alibabacloud/core/EndpointProvider.h index 102d2fe9b..bab86bdb8 100644 --- a/core/include/alibabacloud/core/EndpointProvider.h +++ b/core/include/alibabacloud/core/EndpointProvider.h @@ -1,63 +1,60 @@ /* -* 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. + */ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_ -#include #include -#include +#include #include #include #include #include #include +#include namespace AlibabaCloud { -class ALIBABACLOUD_CORE_EXPORT EndpointProvider : - public Location::LocationClient { - public: +class ALIBABACLOUD_CORE_EXPORT EndpointProvider + : public Location::LocationClient { +public: typedef Outcome EndpointOutcome; EndpointProvider( - const std::shared_ptr& locationClient, - const std::string regionId, - const std::string product, - const std::string serviceCode = std::string(), - int durationSeconds = 3600); + const std::shared_ptr &locationClient, + const std::string regionId, const std::string product, + const std::string serviceCode = std::string(), + int durationSeconds = 3600); - EndpointProvider( - const Credentials &credentials, - const ClientConfiguration &configuration, - const std::string ®ionId, - const std::string &product, - const std::string &serviceCode = std::string(), - int durationSeconds = 3600); + EndpointProvider(const Credentials &credentials, + const ClientConfiguration &configuration, + const std::string ®ionId, const std::string &product, + const std::string &serviceCode = std::string(), + int durationSeconds = 3600); ~EndpointProvider(); EndpointOutcome getEndpoint(); using LocationClient::describeEndpoints; - private: +private: EndpointOutcome loadRemoteEndpoint(); - bool checkExpiry()const; + bool checkExpiry() const; bool loadLocalProductsInfo(); std::string localEndpoint(const std::string regionId, - const std::string product); + const std::string product); std::mutex cachedMutex_; std::string cachedEndpoint_; @@ -67,5 +64,5 @@ class ALIBABACLOUD_CORE_EXPORT EndpointProvider : std::string product_; std::string serviceCode_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_ diff --git a/core/include/alibabacloud/core/Error.h b/core/include/alibabacloud/core/Error.h index 45405814c..859e009c1 100644 --- a/core/include/alibabacloud/core/Error.h +++ b/core/include/alibabacloud/core/Error.h @@ -17,12 +17,12 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ERROR_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_ERROR_H_ -#include #include "CoreExport.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT Error { - public: +public: Error() = default; Error(std::string code, const std::string message); ~Error() = default; @@ -33,18 +33,18 @@ class ALIBABACLOUD_CORE_EXPORT Error { std::string requestId() const; std::string detail() const; void setErrorCode(const std::string &code); - void setErrorMessage(const std::string& message); - void setHost(const std::string& host); - void setRequestId(const std::string& request); - void setDetail(const std::string& detail); + void setErrorMessage(const std::string &message); + void setHost(const std::string &host); + void setRequestId(const std::string &request); + void setDetail(const std::string &detail); - private: +private: std::string errorCode_; std::string message_; std::string host_; std::string requestId_; std::string detail_; }; -} // namespace AlibabaCloud +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ERROR_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ERROR_H_ diff --git a/core/include/alibabacloud/core/Global.h b/core/include/alibabacloud/core/Global.h index dec8c90e0..6bd20ac1a 100644 --- a/core/include/alibabacloud/core/Global.h +++ b/core/include/alibabacloud/core/Global.h @@ -20,22 +20,22 @@ #include "Config.h" #if defined(_WIN32) -# ifdef _MSC_VER -# pragma warning(disable : 4251) -# endif // _MSC_VER -# define ALIBABACLOUD_DECL_EXPORT __declspec(dllexport) -# define ALIBABACLOUD_DECL_IMPORT __declspec(dllimport) +#ifdef _MSC_VER +#pragma warning(disable : 4251) +#endif // _MSC_VER +#define ALIBABACLOUD_DECL_EXPORT __declspec(dllexport) +#define ALIBABACLOUD_DECL_IMPORT __declspec(dllimport) #elif defined(__linux__) -# define ALIBABACLOUD_DECL_EXPORT __attribute__((visibility("default"))) -# define ALIBABACLOUD_DECL_IMPORT __attribute__((visibility("default"))) +#define ALIBABACLOUD_DECL_EXPORT __attribute__((visibility("default"))) +#define ALIBABACLOUD_DECL_IMPORT __attribute__((visibility("default"))) #endif #if !defined(ALIBABACLOUD_DECL_EXPORT) -# define ALIBABACLOUD_DECL_EXPORT +#define ALIBABACLOUD_DECL_EXPORT #endif #if !defined(ALIBABACLOUD_DECL_IMPORT) -# define ALIBABACLOUD_DECL_IMPORT +#define ALIBABACLOUD_DECL_IMPORT #endif -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_GLOBAL_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_GLOBAL_H_ diff --git a/core/include/alibabacloud/core/HmacSha1Signer.h b/core/include/alibabacloud/core/HmacSha1Signer.h index eefa50b34..5eb7008a6 100644 --- a/core/include/alibabacloud/core/HmacSha1Signer.h +++ b/core/include/alibabacloud/core/HmacSha1Signer.h @@ -22,13 +22,13 @@ namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT HmacSha1Signer : public Signer { - public: +public: HmacSha1Signer(); ~HmacSha1Signer(); std::string generate(const std::string &src, - const std::string &secret) const override; + const std::string &secret) const override; }; -} // namespace AlibabaCloud +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_ diff --git a/core/include/alibabacloud/core/HttpClient.h b/core/include/alibabacloud/core/HttpClient.h index b66427163..c06500631 100644 --- a/core/include/alibabacloud/core/HttpClient.h +++ b/core/include/alibabacloud/core/HttpClient.h @@ -17,29 +17,29 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPCLIENT_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPCLIENT_H_ +#include #include #include #include #include -#include namespace AlibabaCloud { class HttpClient { - public: +public: typedef Outcome HttpResponseOutcome; HttpClient(); virtual ~HttpClient(); virtual HttpResponseOutcome makeRequest(const HttpRequest &request) = 0; - NetworkProxy proxy()const; + NetworkProxy proxy() const; void setProxy(const NetworkProxy &proxy); - bool rejectUnauthorized()const; + bool rejectUnauthorized() const; void setRejectUnauthorized(const bool &rejectUnauthorized); - private: +private: NetworkProxy proxy_; bool rejectUnauthorized_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPCLIENT_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPCLIENT_H_ diff --git a/core/include/alibabacloud/core/HttpMessage.h b/core/include/alibabacloud/core/HttpMessage.h index 1e8c9c05d..56e2ead32 100644 --- a/core/include/alibabacloud/core/HttpMessage.h +++ b/core/include/alibabacloud/core/HttpMessage.h @@ -17,18 +17,18 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPMESSAGE_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPMESSAGE_H_ +#include "CoreExport.h" #include #include -#include "CoreExport.h" namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT HttpMessage { - private: +private: struct ALIBABACLOUD_CORE_EXPORT nocaseLess { - bool operator() (const std::string & s1, const std::string & s2) const; + bool operator()(const std::string &s1, const std::string &s2) const; }; - public: +public: enum KnownHeader { Accept, AcceptCharset, @@ -52,31 +52,31 @@ class ALIBABACLOUD_CORE_EXPORT HttpMessage { HttpMessage(const HttpMessage &other); HttpMessage(HttpMessage &&other); - HttpMessage& operator=(const HttpMessage &other); - HttpMessage& operator=(HttpMessage &&other); + HttpMessage &operator=(const HttpMessage &other); + HttpMessage &operator=(HttpMessage &&other); virtual ~HttpMessage(); void addHeader(const HeaderNameType &name, const HeaderValueType &value); void addHeader(KnownHeader header, const HeaderValueType &value); - const char* body()const; - size_t bodySize()const; - bool hasBody()const; + const char *body() const; + size_t bodySize() const; + bool hasBody() const; HeaderValueType header(const HeaderNameType &name) const; HeaderValueType header(KnownHeader header) const; - HeaderCollection headers()const; + HeaderCollection headers() const; void removeHeader(const HeaderNameType &name); void removeHeader(KnownHeader header); void setBody(const char *data, size_t size); void setHeader(const HeaderNameType &name, const HeaderValueType &value); void setHeader(KnownHeader header, const std::string &value); - protected: +protected: HttpMessage(); - private: +private: char *body_; size_t bodySize_; HeaderCollection headers_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPMESSAGE_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPMESSAGE_H_ diff --git a/core/include/alibabacloud/core/HttpRequest.h b/core/include/alibabacloud/core/HttpRequest.h index 67e1b7457..9895ee7c7 100644 --- a/core/include/alibabacloud/core/HttpRequest.h +++ b/core/include/alibabacloud/core/HttpRequest.h @@ -17,41 +17,31 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPREQUEST_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPREQUEST_H_ -#include #include "HttpMessage.h" #include "Url.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT HttpRequest : public HttpMessage { - public: - enum Method { - Get, - Head, - Post, - Put, - Delete, - Connect, - Options, - Patch, - Trace - }; +public: + enum Method { Get, Head, Post, Put, Delete, Connect, Options, Patch, Trace }; explicit HttpRequest(const Url &url = Url(), Method method = Get); ~HttpRequest(); - Method method()const; + Method method() const; void setMethod(Method method); void setUrl(const Url &url); - Url url()const; + Url url() const; long connectTimeout() const; long readTimeout() const; void setConnectTimeout(const long connectTimeout); void setReadTimeout(const long readTimeout); - private: +private: Method method_; Url url_; long connectTimeout_; long readTimeout_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPREQUEST_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPREQUEST_H_ diff --git a/core/include/alibabacloud/core/HttpResponse.h b/core/include/alibabacloud/core/HttpResponse.h index 5caaed4c2..bad8c4831 100644 --- a/core/include/alibabacloud/core/HttpResponse.h +++ b/core/include/alibabacloud/core/HttpResponse.h @@ -17,26 +17,26 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPRESPONSE_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPRESPONSE_H_ -#include #include "CoreExport.h" #include "HttpMessage.h" #include "HttpRequest.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT HttpResponse : public HttpMessage { - public: +public: HttpResponse(); - explicit HttpResponse(const HttpRequest & request); + explicit HttpResponse(const HttpRequest &request); ~HttpResponse(); - HttpRequest request()const; + HttpRequest request() const; void setStatusCode(int code); - int statusCode()const; + int statusCode() const; - private: +private: int statusCode_; HttpRequest request_; }; -} // namespace AlibabaCloud +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPRESPONSE_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPRESPONSE_H_ diff --git a/core/include/alibabacloud/core/InstanceProfileCredentials.h b/core/include/alibabacloud/core/InstanceProfileCredentials.h index a23b64594..1ca4c04aa 100644 --- a/core/include/alibabacloud/core/InstanceProfileCredentials.h +++ b/core/include/alibabacloud/core/InstanceProfileCredentials.h @@ -21,11 +21,11 @@ namespace AlibabaCloud { class InstanceProfileCredentials : public BasicSessionCredentials { - public: +public: InstanceProfileCredentials(); ~InstanceProfileCredentials(); - private: +private: }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_ diff --git a/core/include/alibabacloud/core/InstanceProfileCredentialsProvider.h b/core/include/alibabacloud/core/InstanceProfileCredentialsProvider.h index 3f4c87189..67c11ed3b 100644 --- a/core/include/alibabacloud/core/InstanceProfileCredentialsProvider.h +++ b/core/include/alibabacloud/core/InstanceProfileCredentialsProvider.h @@ -17,36 +17,37 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_ -#include -#include -#include -#include -#include "CredentialsProvider.h" -#include "Credentials.h" #include "../src/EcsMetadataFetcher.h" +#include "Credentials.h" +#include "CredentialsProvider.h" +#include +#include +#include +#include namespace AlibabaCloud { -class ALIBABACLOUD_CORE_EXPORT InstanceProfileCredentialsProvider : - public CredentialsProvider, public EcsMetadataFetcher { - public: +class ALIBABACLOUD_CORE_EXPORT InstanceProfileCredentialsProvider + : public CredentialsProvider, + public EcsMetadataFetcher { +public: InstanceProfileCredentialsProvider(const std::string &roleName, - int durationSeconds = 3600); + int durationSeconds = 3600); ~InstanceProfileCredentialsProvider(); - std::string roleName()const; + std::string roleName() const; Credentials getCredentials() override; + using EcsMetadataFetcher::getMetadata; using EcsMetadataFetcher::roleName; using EcsMetadataFetcher::setRoleName; - using EcsMetadataFetcher::getMetadata; - private: +private: void loadCredentials(); - bool checkExpiry()const; + bool checkExpiry() const; std::mutex cachedMutex_; Credentials cachedCredentials_; int durationSeconds_; std::chrono::system_clock::time_point expiry_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_ diff --git a/core/include/alibabacloud/core/NetworkProxy.h b/core/include/alibabacloud/core/NetworkProxy.h index c5b6e8eb2..033f6b31d 100644 --- a/core/include/alibabacloud/core/NetworkProxy.h +++ b/core/include/alibabacloud/core/NetworkProxy.h @@ -17,26 +17,20 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_NETWORKPROXY_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_NETWORKPROXY_H_ -#include #include "CoreExport.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT NetworkProxy { - public: - enum Type { - None = 0, - Http, - Socks5 - }; - NetworkProxy(Type type = None, - const std::string &hostName = "", - uint16_t port = 0, - const std::string &user = "", - const std::string &password = ""); +public: + enum Type { None = 0, Http, Socks5 }; + NetworkProxy(Type type = None, const std::string &hostName = "", + uint16_t port = 0, const std::string &user = "", + const std::string &password = ""); ~NetworkProxy(); - std::string hostName() const; - std::string password() const; + std::string hostName() const; + std::string password() const; uint16_t port() const; void setHostName(const std::string &hostName); void setPassword(const std::string &password); @@ -44,14 +38,14 @@ class ALIBABACLOUD_CORE_EXPORT NetworkProxy { void setType(Type type); void setUser(const std::string &user); Type type() const; - std::string user() const; + std::string user() const; - private: +private: std::string hostName_; std::string password_; uint16_t port_; Type type_; std::string user_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_NETWORKPROXY_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_NETWORKPROXY_H_ diff --git a/core/include/alibabacloud/core/Outcome.h b/core/include/alibabacloud/core/Outcome.h index 9b3d1677a..9f974a4da 100644 --- a/core/include/alibabacloud/core/Outcome.h +++ b/core/include/alibabacloud/core/Outcome.h @@ -20,24 +20,15 @@ #include namespace AlibabaCloud { -template -class Outcome { - public: - Outcome() : - success_(true), e_(), r_() { } - explicit Outcome(const E &e) : - e_(e), success_(false), r_() { } - explicit Outcome(const R &r) : - r_(r), success_(true), e_() { } - Outcome(const Outcome &other) : - success_(other.success_), - e_(other.e_), - r_(other.r_) - { } - Outcome(Outcome &&other) { - *this = std::move(other); - } - Outcome & operator=(const Outcome &other) { +template class Outcome { +public: + Outcome() : success_(true), e_(), r_() {} + explicit Outcome(const E &e) : e_(e), success_(false), r_() {} + explicit Outcome(const R &r) : r_(r), success_(true), e_() {} + Outcome(const Outcome &other) + : success_(other.success_), e_(other.e_), r_(other.r_) {} + Outcome(Outcome &&other) { *this = std::move(other); } + Outcome &operator=(const Outcome &other) { if (this != &other) { success_ = other.success_; e_ = other.e_; @@ -45,7 +36,7 @@ class Outcome { } return *this; } - Outcome & operator=(Outcome &&other) { + Outcome &operator=(Outcome &&other) { if (this != &other) { success_ = other.success_; r_ = other.r_; @@ -54,14 +45,14 @@ class Outcome { return *this; } - bool isSuccess()const { return success_; } - E error()const { return e_; } - R result()const { return r_; } + bool isSuccess() const { return success_; } + E error() const { return e_; } + R result() const { return r_; } - private: +private: bool success_; E e_; R r_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_OUTCOME_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_OUTCOME_H_ diff --git a/core/include/alibabacloud/core/RoaServiceClient.h b/core/include/alibabacloud/core/RoaServiceClient.h index 9896aed59..d3f79cce6 100644 --- a/core/include/alibabacloud/core/RoaServiceClient.h +++ b/core/include/alibabacloud/core/RoaServiceClient.h @@ -17,39 +17,43 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICECLIENT_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICECLIENT_H_ -#include -#include -#include #include "CoreClient.h" #include "CredentialsProvider.h" #include "HmacSha1Signer.h" #include "HttpRequest.h" #include "RoaServiceRequest.h" +#include +#include +#include namespace AlibabaCloud { class RoaErrorMarshaller; class ALIBABACLOUD_CORE_EXPORT RoaServiceClient : public CoreClient { - public: +public: typedef Outcome JsonOutcome; - RoaServiceClient(const std::string & servicename, - const std::shared_ptr &credentialsProvider, - const ClientConfiguration &configuration, - const std::shared_ptr &signer = - std::make_shared()); + RoaServiceClient( + const std::string &servicename, + const std::shared_ptr &credentialsProvider, + const ClientConfiguration &configuration, + const std::shared_ptr &signer = + std::make_shared()); virtual ~RoaServiceClient(); - protected: - JsonOutcome makeRequest(const std::string &endpoint, - const RoaServiceRequest &msg, HttpRequest::Method method = HttpRequest::Method::Get) const; - HttpRequest buildHttpRequest(const std::string &endpoint, - const ServiceRequest &msg, HttpRequest::Method method) const override; - HttpRequest buildHttpRequest(const std::string &endpoint, - const RoaServiceRequest &msg, HttpRequest::Method method) const; +protected: + JsonOutcome + makeRequest(const std::string &endpoint, const RoaServiceRequest &msg, + HttpRequest::Method method = HttpRequest::Method::Get) const; + HttpRequest buildHttpRequest(const std::string &endpoint, + const ServiceRequest &msg, + HttpRequest::Method method) const override; + HttpRequest buildHttpRequest(const std::string &endpoint, + const RoaServiceRequest &msg, + HttpRequest::Method method) const; - private: +private: std::shared_ptr credentialsProvider_; std::shared_ptr signer_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICECLIENT_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICECLIENT_H_ diff --git a/core/include/alibabacloud/core/RoaServiceRequest.h b/core/include/alibabacloud/core/RoaServiceRequest.h index 33d29e2f7..e15dd4348 100644 --- a/core/include/alibabacloud/core/RoaServiceRequest.h +++ b/core/include/alibabacloud/core/RoaServiceRequest.h @@ -22,15 +22,15 @@ namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT RoaServiceRequest : public ServiceRequest { - public: +public: RoaServiceRequest(const std::string &product, const std::string &version); virtual ~RoaServiceRequest(); - using ServiceRequest::setParameter; - using ServiceRequest::setContent; using ServiceRequest::parameter; - using ServiceRequest::setScheme; - using ServiceRequest::setResourcePath; + using ServiceRequest::setContent; using ServiceRequest::setMethod; + using ServiceRequest::setParameter; + using ServiceRequest::setResourcePath; + using ServiceRequest::setScheme; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_ diff --git a/core/include/alibabacloud/core/RpcServiceClient.h b/core/include/alibabacloud/core/RpcServiceClient.h index 54912aa7d..30dc3c7a9 100644 --- a/core/include/alibabacloud/core/RpcServiceClient.h +++ b/core/include/alibabacloud/core/RpcServiceClient.h @@ -17,47 +17,51 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_ -#include -#include -#include #include "CoreClient.h" #include "CredentialsProvider.h" #include "HmacSha1Signer.h" #include "HttpRequest.h" -#include "RpcServiceRequest.h" #include "Outcome.h" +#include "RpcServiceRequest.h" +#include +#include +#include namespace AlibabaCloud { class RpcErrorMarshaller; class RpcServiceRequest; class ALIBABACLOUD_CORE_EXPORT RpcServiceClient : public CoreClient { - public: +public: typedef Outcome JsonOutcome; - RpcServiceClient(const std::string & servicename, - const std::shared_ptr &credentialsProvider, - const ClientConfiguration &configuration, - const std::shared_ptr &signer = - std::make_shared()); + RpcServiceClient( + const std::string &servicename, + const std::shared_ptr &credentialsProvider, + const ClientConfiguration &configuration, + const std::shared_ptr &signer = + std::make_shared()); virtual ~RpcServiceClient(); std::shared_ptr credentialsProvider() { return credentialsProvider_; } - using CoreClient::configuration; using CoreClient::AttemptRequest; + using CoreClient::configuration; - protected: - virtual JsonOutcome makeRequest(const std::string &endpoint, - const RpcServiceRequest &msg, HttpRequest::Method method = HttpRequest::Method::Get) const; - HttpRequest buildHttpRequest(const std::string &endpoint, - const ServiceRequest &msg, HttpRequest::Method method) const override; - HttpRequest buildHttpRequest(const std::string &endpoint, - const RpcServiceRequest &msg, HttpRequest::Method method) const; +protected: + virtual JsonOutcome + makeRequest(const std::string &endpoint, const RpcServiceRequest &msg, + HttpRequest::Method method = HttpRequest::Method::Get) const; + HttpRequest buildHttpRequest(const std::string &endpoint, + const ServiceRequest &msg, + HttpRequest::Method method) const override; + HttpRequest buildHttpRequest(const std::string &endpoint, + const RpcServiceRequest &msg, + HttpRequest::Method method) const; - private: +private: std::shared_ptr credentialsProvider_; std::shared_ptr signer_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_ diff --git a/core/include/alibabacloud/core/RpcServiceRequest.h b/core/include/alibabacloud/core/RpcServiceRequest.h index 2ea370db4..b995bbd41 100644 --- a/core/include/alibabacloud/core/RpcServiceRequest.h +++ b/core/include/alibabacloud/core/RpcServiceRequest.h @@ -22,17 +22,17 @@ namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT RpcServiceRequest : public ServiceRequest { - public: +public: RpcServiceRequest(const std::string &product, const std::string &version, - const std::string & action); + const std::string &action); virtual ~RpcServiceRequest(); - std::string actionName()const; + std::string actionName() const; using ServiceRequest::setMethod; using ServiceRequest::setScheme; protected: void setActionName(const std::string &name); }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_ diff --git a/core/include/alibabacloud/core/Runnable.h b/core/include/alibabacloud/core/Runnable.h index 6982874e2..c62d2e2c5 100644 --- a/core/include/alibabacloud/core/Runnable.h +++ b/core/include/alibabacloud/core/Runnable.h @@ -1,33 +1,33 @@ /* -* 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. + */ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_RUNNABLE_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_RUNNABLE_H_ -#include #include "CoreExport.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT Runnable { - public: +public: explicit Runnable(const std::function f); - void run()const; + void run() const; - private: +private: std::function f_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_RUNNABLE_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_RUNNABLE_H_ diff --git a/core/include/alibabacloud/core/ServiceRequest.h b/core/include/alibabacloud/core/ServiceRequest.h index 71e888ded..ab744867f 100644 --- a/core/include/alibabacloud/core/ServiceRequest.h +++ b/core/include/alibabacloud/core/ServiceRequest.h @@ -18,10 +18,10 @@ #define CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICEREQUEST_H_ #include "CoreExport.h" +#include "HttpRequest.h" #include "Url.h" #include #include -#include "HttpRequest.h" namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT ServiceRequest { @@ -47,11 +47,13 @@ public: void setConnectTimeout(const long connectTimeout); void setReadTimeout(const long readTimeout); void setMethod(const HttpRequest::Method method); - void setHeader(const ParameterNameType &name, const ParameterValueType &value); + void setHeader(const ParameterNameType &name, + const ParameterValueType &value); ParameterValueType getHeader(const ParameterNameType &name); void removeHeader(const ParameterNameType &name); ParameterCollection headers() const; - void setBodyParameter(const ParameterNameType &name, const ParameterValueType &value); + void setBodyParameter(const ParameterNameType &name, + const ParameterValueType &value); protected: ServiceRequest(const std::string &product, const std::string &version); @@ -73,7 +75,8 @@ protected: const ParameterValueType &value); void setParameters(const ParameterCollection ¶ms); - void setJsonParameters(const ParameterNameType &name, const ParameterCollection ¶ms); + void setJsonParameters(const ParameterNameType &name, + const ParameterCollection ¶ms); void setResourcePath(const std::string &path); void setProduct(const std::string &product); void setVersion(const std::string &version); diff --git a/core/include/alibabacloud/core/ServiceResult.h b/core/include/alibabacloud/core/ServiceResult.h index 8b4b160de..de48b54f5 100644 --- a/core/include/alibabacloud/core/ServiceResult.h +++ b/core/include/alibabacloud/core/ServiceResult.h @@ -17,23 +17,23 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICERESULT_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICERESULT_H_ -#include #include "CoreExport.h" +#include namespace AlibabaCloud { class PayloadReader; class ALIBABACLOUD_CORE_EXPORT ServiceResult { - public: +public: ServiceResult(); virtual ~ServiceResult(); - std::string requestId()const; + std::string requestId() const; - protected: +protected: void setRequestId(const std::string &requestId); - private: +private: std::string requestId_; }; -} // namespace AlibabaCloud +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICERESULT_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICERESULT_H_ diff --git a/core/include/alibabacloud/core/Signer.h b/core/include/alibabacloud/core/Signer.h index 361de9d1b..53e869f06 100644 --- a/core/include/alibabacloud/core/Signer.h +++ b/core/include/alibabacloud/core/Signer.h @@ -17,31 +17,31 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_SIGNER_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_SIGNER_H_ -#include #include "CoreExport.h" +#include namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT Signer { - public: +public: enum Type { HmacSha1, }; virtual ~Signer(); virtual std::string generate(const std::string &src, - const std::string &secret)const = 0; - std::string name()const; + const std::string &secret) const = 0; + std::string name() const; Type type() const; - std::string version()const; + std::string version() const; - protected: +protected: Signer(Type type, const std::string &name, - const std::string &version = "1.0"); + const std::string &version = "1.0"); - private: +private: std::string name_; std::string version_; Type type_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SIGNER_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SIGNER_H_ diff --git a/core/include/alibabacloud/core/SimpleCredentialsProvider.h b/core/include/alibabacloud/core/SimpleCredentialsProvider.h index 4037a2bcc..c23d8cc4a 100644 --- a/core/include/alibabacloud/core/SimpleCredentialsProvider.h +++ b/core/include/alibabacloud/core/SimpleCredentialsProvider.h @@ -23,16 +23,16 @@ namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT SimpleCredentialsProvider : public CredentialsProvider { - public: +public: explicit SimpleCredentialsProvider(const Credentials &credentials); SimpleCredentialsProvider(const std::string &accessKeyId, - const std::string &accessKeySecret); + const std::string &accessKeySecret); ~SimpleCredentialsProvider(); Credentials getCredentials() override; - private: +private: Credentials credentials_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_ diff --git a/core/include/alibabacloud/core/StsAssumeRoleCredentialsProvider.h b/core/include/alibabacloud/core/StsAssumeRoleCredentialsProvider.h index 08becc69c..c67e08213 100644 --- a/core/include/alibabacloud/core/StsAssumeRoleCredentialsProvider.h +++ b/core/include/alibabacloud/core/StsAssumeRoleCredentialsProvider.h @@ -1,18 +1,18 @@ /* -* 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. + */ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_STSASSUMEROLECREDENTIALSPROVIDER_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_STSASSUMEROLECREDENTIALSPROVIDER_H_ @@ -25,23 +25,23 @@ namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT StsAssumeRoleCredentialsProvider - : public CredentialsProvider, public Sts::StsClient { - public: - StsAssumeRoleCredentialsProvider( - const Credentials &credentials, - const ClientConfiguration &configuration, - const std::string &roleArn, - const std::string &roleSessionName, - const std::string &policy = "", - int durationSeconds = 3600); + : public CredentialsProvider, + public Sts::StsClient { +public: + StsAssumeRoleCredentialsProvider(const Credentials &credentials, + const ClientConfiguration &configuration, + const std::string &roleArn, + const std::string &roleSessionName, + const std::string &policy = "", + int durationSeconds = 3600); ~StsAssumeRoleCredentialsProvider(); Credentials getCredentials() override; using StsClient::assumeRole; - private: +private: void loadCredentials(); - bool checkExpiry()const; + bool checkExpiry() const; std::mutex cachedMutex_; Credentials cachedCredentials_; @@ -51,5 +51,5 @@ class ALIBABACLOUD_CORE_EXPORT StsAssumeRoleCredentialsProvider std::string roleArn_; std::string roleSessionName_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_STSASSUMEROLECREDENTIALSPROVIDER_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_STSASSUMEROLECREDENTIALSPROVIDER_H_ diff --git a/core/include/alibabacloud/core/Url.h b/core/include/alibabacloud/core/Url.h index 18174879f..96af1d9cf 100644 --- a/core/include/alibabacloud/core/Url.h +++ b/core/include/alibabacloud/core/Url.h @@ -22,13 +22,13 @@ namespace AlibabaCloud { class ALIBABACLOUD_CORE_EXPORT Url { - public: +public: explicit Url(const std::string &url = ""); Url(const Url &other) = default; Url(Url &&other) = default; ~Url(); - Url & operator=(const Url &url) = default; - Url & operator=(Url &&other) = default; + Url &operator=(const Url &url) = default; + Url &operator=(Url &&other) = default; bool operator==(const Url &url) const; bool operator!=(const Url &url) const; @@ -38,11 +38,11 @@ class ALIBABACLOUD_CORE_EXPORT Url { void fromString(const std::string &url); bool hasFragment() const; bool hasQuery() const; - std::string host()const; + std::string host() const; bool isEmpty() const; bool isValid() const; - int port()const; - std::string password() const; + int port() const; + std::string password() const; std::string path() const; std::string query() const; std::string scheme() const; @@ -58,9 +58,9 @@ class ALIBABACLOUD_CORE_EXPORT Url { void setUserName(const std::string &userName); std::string toString() const; std::string userInfo() const; - std::string userName() const; + std::string userName() const; - private: +private: std::string scheme_; std::string userName_; std::string password_; @@ -70,5 +70,5 @@ class ALIBABACLOUD_CORE_EXPORT Url { std::string query_; std::string fragment_; }; -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_URL_H_ +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_URL_H_ diff --git a/core/include/alibabacloud/core/Utils.h b/core/include/alibabacloud/core/Utils.h index 82dca4078..0667ab1d0 100644 --- a/core/include/alibabacloud/core/Utils.h +++ b/core/include/alibabacloud/core/Utils.h @@ -23,8 +23,7 @@ #include #include -namespace AlibabaCloud -{ +namespace AlibabaCloud { std::string ComputeContentMD5(const char *data, size_t size); std::string GenerateUuid(); std::string HttpMethodToString(HttpRequest::Method method); diff --git a/core/include/alibabacloud/core/location/LocationClient.h b/core/include/alibabacloud/core/location/LocationClient.h index e26c4c356..75aebd9e5 100644 --- a/core/include/alibabacloud/core/location/LocationClient.h +++ b/core/include/alibabacloud/core/location/LocationClient.h @@ -17,50 +17,51 @@ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_ +#include "model/DescribeEndpointsRequest.h" +#include "model/DescribeEndpointsResult.h" #include #include #include #include #include -#include "model/DescribeEndpointsRequest.h" -#include "model/DescribeEndpointsResult.h" - namespace AlibabaCloud { namespace Location { class ALIBABACLOUD_CORE_EXPORT LocationClient : public RpcServiceClient { - public: +public: typedef Outcome DescribeEndpointsOutcome; typedef std::future DescribeEndpointsOutcomeCallable; - typedef std::function&)> + typedef std::function &)> DescribeEndpointsAsyncHandler; LocationClient(const Credentials &credentials, - const ClientConfiguration &configuration); + const ClientConfiguration &configuration); LocationClient( const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); LocationClient(const std::string &accessKeyId, - const std::string &accessKeySecret, - const ClientConfiguration &configuration); + const std::string &accessKeySecret, + const ClientConfiguration &configuration); LocationClient( - const std::shared_ptr& locationClient); + const std::shared_ptr &locationClient); ~LocationClient(); - virtual DescribeEndpointsOutcome describeEndpoints( - const Model::DescribeEndpointsRequest &request)const; - void describeEndpointsAsync(const Model::DescribeEndpointsRequest& request, - const DescribeEndpointsAsyncHandler& handler, - const std::shared_ptr& context = nullptr) const; + virtual DescribeEndpointsOutcome + describeEndpoints(const Model::DescribeEndpointsRequest &request) const; + void describeEndpointsAsync( + const Model::DescribeEndpointsRequest &request, + const DescribeEndpointsAsyncHandler &handler, + const std::shared_ptr &context = nullptr) const; DescribeEndpointsOutcomeCallable describeEndpointsCallable( - const Model::DescribeEndpointsRequest& request) const; - using RpcServiceClient::makeRequest; + const Model::DescribeEndpointsRequest &request) const; using RpcServiceClient::configuration; + using RpcServiceClient::makeRequest; }; -} // namespace Location -} // namespace AlibabaCloud +} // namespace Location +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_ diff --git a/core/include/alibabacloud/core/location/LocationRequest.h b/core/include/alibabacloud/core/location/LocationRequest.h index c32ab9dd5..2212a2235 100644 --- a/core/include/alibabacloud/core/location/LocationRequest.h +++ b/core/include/alibabacloud/core/location/LocationRequest.h @@ -23,13 +23,13 @@ namespace AlibabaCloud { namespace Location { class ALIBABACLOUD_CORE_EXPORT LocationRequest : public RpcServiceRequest { - public: - explicit LocationRequest(const std::string & action); +public: + explicit LocationRequest(const std::string &action); virtual ~LocationRequest(); - private: +private: }; -} // namespace Location -} // namespace AlibabaCloud +} // namespace Location +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_ diff --git a/core/include/alibabacloud/core/location/model/DescribeEndpointsRequest.h b/core/include/alibabacloud/core/location/model/DescribeEndpointsRequest.h index 7314349b8..62336c6c8 100644 --- a/core/include/alibabacloud/core/location/model/DescribeEndpointsRequest.h +++ b/core/include/alibabacloud/core/location/model/DescribeEndpointsRequest.h @@ -25,18 +25,18 @@ namespace Location { namespace Model { class ALIBABACLOUD_CORE_EXPORT DescribeEndpointsRequest : public LocationRequest { - public: +public: DescribeEndpointsRequest(); ~DescribeEndpointsRequest(); - std::string serviceCode()const; - void setServiceCode(const std::string& serviceCode); - std::string id()const; - void setId(const std::string& id); - std::string type()const; - void setType(const std::string& type); + std::string serviceCode() const; + void setServiceCode(const std::string &serviceCode); + std::string id() const; + void setId(const std::string &id); + std::string type() const; + void setType(const std::string &type); }; -} // namespace Model -} // namespace Location -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSREQUEST_H_ +} // namespace Model +} // namespace Location +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSREQUEST_H_ diff --git a/core/include/alibabacloud/core/location/model/DescribeEndpointsResult.h b/core/include/alibabacloud/core/location/model/DescribeEndpointsResult.h index 75f0065a3..15a942181 100644 --- a/core/include/alibabacloud/core/location/model/DescribeEndpointsResult.h +++ b/core/include/alibabacloud/core/location/model/DescribeEndpointsResult.h @@ -19,14 +19,14 @@ #include #include -#include #include +#include namespace AlibabaCloud { namespace Location { namespace Model { class ALIBABACLOUD_CORE_EXPORT DescribeEndpointsResult : public ServiceResult { - public: +public: struct Endpoint { std::string endpoint; std::string id; @@ -40,20 +40,20 @@ class ALIBABACLOUD_CORE_EXPORT DescribeEndpointsResult : public ServiceResult { explicit DescribeEndpointsResult(const std::string &payload); ~DescribeEndpointsResult(); - std::vector endpoints()const; + std::vector endpoints() const; void setEndpoints(const std::vector &endpoints); - bool success()const; + bool success() const; void setSuccess(const bool &success); - protected: +protected: void parse(const std::string &payload); - private: +private: std::vector endpoints_; bool success_; }; -} // namespace Model -} // namespace Location -} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_ +} // namespace Model +} // namespace Location +} // namespace AlibabaCloud +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_ diff --git a/core/include/alibabacloud/core/sts/StsClient.h b/core/include/alibabacloud/core/sts/StsClient.h index b758b77f3..1f66655d9 100644 --- a/core/include/alibabacloud/core/sts/StsClient.h +++ b/core/include/alibabacloud/core/sts/StsClient.h @@ -1,77 +1,81 @@ /* -* 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. + */ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSCLIENT_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSCLIENT_H_ +#include "model/AssumeRoleRequest.h" +#include "model/AssumeRoleResult.h" +#include "model/GetCallerIdentityRequest.h" +#include "model/GetCallerIdentityResult.h" #include #include #include #include #include -#include "model/AssumeRoleRequest.h" -#include "model/AssumeRoleResult.h" -#include "model/GetCallerIdentityRequest.h" -#include "model/GetCallerIdentityResult.h" - namespace AlibabaCloud { namespace Sts { class ALIBABACLOUD_CORE_EXPORT StsClient : public RpcServiceClient { - public: +public: typedef Outcome AssumeRoleOutcome; typedef std::future AssumeRoleOutcomeCallable; - typedef std::function&)> AssumeRoleAsyncHandler; + typedef std::function &)> + AssumeRoleAsyncHandler; typedef Outcome - GetCallerIdentityOutcome; + GetCallerIdentityOutcome; typedef std::future - GetCallerIdentityOutcomeCallable; - typedef std::function&)> - GetCallerIdentityAsyncHandler; + GetCallerIdentityOutcomeCallable; + typedef std::function &)> + GetCallerIdentityAsyncHandler; StsClient(const Credentials &credentials, - const ClientConfiguration &configuration); + const ClientConfiguration &configuration); StsClient(const std::shared_ptr &credentialsProvider, - const ClientConfiguration &configuration); + const ClientConfiguration &configuration); StsClient(const std::string &accessKeyId, const std::string &accessKeySecret, - const ClientConfiguration &configuration); + const ClientConfiguration &configuration); ~StsClient(); - virtual 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; - GetCallerIdentityOutcome getCallerIdentity( - const Model::GetCallerIdentityRequest &request)const; - void getCallerIdentityAsync(const Model::GetCallerIdentityRequest& request, - const GetCallerIdentityAsyncHandler& handler, - const std::shared_ptr& context = nullptr) const; + virtual 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; + 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; + const Model::GetCallerIdentityRequest &request) const; using RpcServiceClient::makeRequest; }; - } // namespace Sts -} // namespace AlibabaCloud +} // namespace Sts +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSCLIENT_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSCLIENT_H_ diff --git a/core/include/alibabacloud/core/sts/StsRequest.h b/core/include/alibabacloud/core/sts/StsRequest.h index d181cc3db..3e37d2582 100644 --- a/core/include/alibabacloud/core/sts/StsRequest.h +++ b/core/include/alibabacloud/core/sts/StsRequest.h @@ -1,18 +1,18 @@ /* -* 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. + */ #ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSREQUEST_H_ #define CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSREQUEST_H_ @@ -23,13 +23,13 @@ namespace AlibabaCloud { namespace Sts { class ALIBABACLOUD_CORE_EXPORT StsRequest : public RpcServiceRequest { - public: - explicit StsRequest(const std::string & action); +public: + explicit StsRequest(const std::string &action); virtual ~StsRequest(); - private: +private: }; -} // namespace Sts -} // namespace AlibabaCloud +} // namespace Sts +} // namespace AlibabaCloud -#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSREQUEST_H_ +#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSREQUEST_H_ diff --git a/core/include/alibabacloud/core/sts/model/AssumeRoleRequest.h b/core/include/alibabacloud/core/sts/model/AssumeRoleRequest.h index 20d3e4512..1e65bbb79 100644 --- a/core/include/alibabacloud/core/sts/model/AssumeRoleRequest.h +++ b/core/include/alibabacloud/core/sts/model/AssumeRoleRequest.h @@ -1,43 +1,43 @@ /* -* 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. + */ #ifndef ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLEREQUEST_H_ #define ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLEREQUEST_H_ -#include #include +#include namespace AlibabaCloud { - namespace Sts { - namespace Model { - class ALIBABACLOUD_CORE_EXPORT AssumeRoleRequest : public StsRequest { - public: - AssumeRoleRequest(); - ~AssumeRoleRequest(); +namespace Sts { +namespace Model { +class ALIBABACLOUD_CORE_EXPORT AssumeRoleRequest : public StsRequest { +public: + AssumeRoleRequest(); + ~AssumeRoleRequest(); - int durationSeconds()const; - std::string policy()const; - std::string roleArn()const; - std::string roleSessionName()const; - void setDurationSeconds(int durationSeconds); - void setPolicy(const std::string &policy); - void setRoleArn(const std::string & roleArn); - void setRoleSessionName(const std::string & roleSessionName); - }; - } - } -} + int durationSeconds() const; + std::string policy() const; + std::string roleArn() const; + std::string roleSessionName() const; + void setDurationSeconds(int durationSeconds); + void setPolicy(const std::string &policy); + void setRoleArn(const std::string &roleArn); + void setRoleSessionName(const std::string &roleSessionName); +}; +} // namespace Model +} // namespace Sts +} // namespace AlibabaCloud #endif // !ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLEREQUEST_H_ diff --git a/core/include/alibabacloud/core/sts/model/AssumeRoleResult.h b/core/include/alibabacloud/core/sts/model/AssumeRoleResult.h index 906b88374..f2c8be81d 100644 --- a/core/include/alibabacloud/core/sts/model/AssumeRoleResult.h +++ b/core/include/alibabacloud/core/sts/model/AssumeRoleResult.h @@ -1,18 +1,18 @@ /* -* 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. + */ #ifndef ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLERESULT_H_ #define ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLERESULT_H_ @@ -20,34 +20,35 @@ #include namespace AlibabaCloud { - namespace Sts { - namespace Model { - class ALIBABACLOUD_CORE_EXPORT AssumeRoleResult : public ServiceResult { - public: - struct AssumedRoleUser { - std::string arn; - std::string assumedRoleId; - }; - struct Credentials { - std::string accessKeyId; - std::string accessKeySecret; - std::string expiration; - std::string securityToken; - }; +namespace Sts { +namespace Model { +class ALIBABACLOUD_CORE_EXPORT AssumeRoleResult : public ServiceResult { +public: + struct AssumedRoleUser { + std::string arn; + std::string assumedRoleId; + }; + struct Credentials { + std::string accessKeyId; + std::string accessKeySecret; + std::string expiration; + std::string securityToken; + }; - AssumeRoleResult(); - explicit AssumeRoleResult(const std::string &payload); - ~AssumeRoleResult(); + AssumeRoleResult(); + explicit AssumeRoleResult(const std::string &payload); + ~AssumeRoleResult(); - AssumedRoleUser assumedRoleUser()const; - Credentials credentials()const; - private: - void parse(const std::string &payload); + AssumedRoleUser assumedRoleUser() const; + Credentials credentials() const; - AssumedRoleUser assumedRoleUser_; - Credentials credentials_; - }; - } - } -} +private: + void parse(const std::string &payload); + + AssumedRoleUser assumedRoleUser_; + Credentials credentials_; +}; +} // namespace Model +} // namespace Sts +} // namespace AlibabaCloud #endif // !ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLERESULT_H_ diff --git a/core/include/alibabacloud/core/sts/model/GetCallerIdentityRequest.h b/core/include/alibabacloud/core/sts/model/GetCallerIdentityRequest.h index e1ea02c52..5ac376f41 100644 --- a/core/include/alibabacloud/core/sts/model/GetCallerIdentityRequest.h +++ b/core/include/alibabacloud/core/sts/model/GetCallerIdentityRequest.h @@ -1,37 +1,36 @@ /* -* 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. + */ #ifndef ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYREQUEST_H_ #define ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYREQUEST_H_ -#include #include +#include namespace AlibabaCloud { - namespace Sts { - namespace Model { - class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityRequest : public StsRequest { - public: - GetCallerIdentityRequest(); - ~GetCallerIdentityRequest(); +namespace Sts { +namespace Model { +class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityRequest : public StsRequest { +public: + GetCallerIdentityRequest(); + ~GetCallerIdentityRequest(); - private: - - }; - } - } -} +private: +}; +} // namespace Model +} // namespace Sts +} // namespace AlibabaCloud #endif // !ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYREQUEST_H_ diff --git a/core/include/alibabacloud/core/sts/model/GetCallerIdentityResult.h b/core/include/alibabacloud/core/sts/model/GetCallerIdentityResult.h index 2f1c52e1f..33dfb8b87 100644 --- a/core/include/alibabacloud/core/sts/model/GetCallerIdentityResult.h +++ b/core/include/alibabacloud/core/sts/model/GetCallerIdentityResult.h @@ -1,18 +1,18 @@ /* -* 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. + */ #ifndef ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYRESULT_H_ #define ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYRESULT_H_ @@ -20,26 +20,27 @@ #include namespace AlibabaCloud { - namespace Sts { - namespace Model { - class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityResult : public ServiceResult { - public: - GetCallerIdentityResult(); - explicit GetCallerIdentityResult(const std::string &payload); - ~GetCallerIdentityResult(); +namespace Sts { +namespace Model { +class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityResult : public ServiceResult { +public: + GetCallerIdentityResult(); + explicit GetCallerIdentityResult(const std::string &payload); + ~GetCallerIdentityResult(); - std::string accountId(); - std::string arn()const; - std::string userId()const; - private: - void parse(const std::string &payload); + std::string accountId(); + std::string arn() const; + std::string userId() const; - std::string accountId_; - std::string arn_; - std::string userId_; - }; - } - } -} +private: + void parse(const std::string &payload); + + std::string accountId_; + std::string arn_; + std::string userId_; +}; +} // namespace Model +} // namespace Sts +} // namespace AlibabaCloud #endif // !ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYRESULT_H_ diff --git a/core/src/location/LocationClient.cc b/core/src/location/LocationClient.cc index 8bcbff265..7ad9f647c 100644 --- a/core/src/location/LocationClient.cc +++ b/core/src/location/LocationClient.cc @@ -14,75 +14,68 @@ * limitations under the License. */ -#include #include +#include using namespace AlibabaCloud; using namespace AlibabaCloud::Location; namespace { - const std::string SERVICE_NAME = "Location"; - const std::string ENDPOINT = "location.aliyuncs.com"; -} +const std::string SERVICE_NAME = "Location"; +const std::string ENDPOINT = "location.aliyuncs.com"; +} // namespace LocationClient::LocationClient(const Credentials &credentials, - const ClientConfiguration &configuration) : - RpcServiceClient(SERVICE_NAME, - std::make_shared(credentials), configuration) { -} + const ClientConfiguration &configuration) + : RpcServiceClient(SERVICE_NAME, + std::make_shared(credentials), + configuration) {} LocationClient::LocationClient( - const std::shared_ptr& credentialsProvider, - const ClientConfiguration & configuration) : - RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) { -} + const std::shared_ptr &credentialsProvider, + const ClientConfiguration &configuration) + : RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) {} -LocationClient::LocationClient(const std::string & accessKeyId, - const std::string & accessKeySecret, - const ClientConfiguration & configuration) : - RpcServiceClient(SERVICE_NAME, - std::make_shared(accessKeyId, - accessKeySecret), configuration) { -} +LocationClient::LocationClient(const std::string &accessKeyId, + const std::string &accessKeySecret, + const ClientConfiguration &configuration) + : RpcServiceClient(SERVICE_NAME, + std::make_shared( + accessKeyId, accessKeySecret), + configuration) {} LocationClient::LocationClient( - const std::shared_ptr& locationClient): - RpcServiceClient(SERVICE_NAME, - locationClient->credentialsProvider(), - locationClient->configuration()) { -} - + const std::shared_ptr &locationClient) + : RpcServiceClient(SERVICE_NAME, locationClient->credentialsProvider(), + locationClient->configuration()) {} LocationClient::~LocationClient() {} LocationClient::DescribeEndpointsOutcome LocationClient::describeEndpoints( - const Model::DescribeEndpointsRequest &request) const { + const Model::DescribeEndpointsRequest &request) const { auto outcome = makeRequest(ENDPOINT, request); if (outcome.isSuccess()) return DescribeEndpointsOutcome( - Model::DescribeEndpointsResult(outcome.result())); + Model::DescribeEndpointsResult(outcome.result())); else return DescribeEndpointsOutcome(outcome.error()); } void LocationClient::describeEndpointsAsync( - const Model::DescribeEndpointsRequest& request, - const DescribeEndpointsAsyncHandler& handler, - const std::shared_ptr& context) const { - std::async(std::launch::async, - [this, request, handler, context]() { + const Model::DescribeEndpointsRequest &request, + const DescribeEndpointsAsyncHandler &handler, + const std::shared_ptr &context) const { + std::async(std::launch::async, [this, request, handler, context]() { handler(this, request, describeEndpoints(request), context); }); } LocationClient::DescribeEndpointsOutcomeCallable LocationClient::describeEndpointsCallable( - const Model::DescribeEndpointsRequest &request) const { + const Model::DescribeEndpointsRequest &request) const { auto task = std::make_shared>( - [this, request]() { - return this->describeEndpoints(request); - }); + [this, request]() { return this->describeEndpoints(request); }); asyncExecute(new Runnable([task]() { (*task)(); })); return task->get_future(); diff --git a/core/src/location/LocationRequest.cc b/core/src/location/LocationRequest.cc index 2009c5f3d..e0034157a 100644 --- a/core/src/location/LocationRequest.cc +++ b/core/src/location/LocationRequest.cc @@ -18,9 +18,7 @@ using namespace AlibabaCloud::Location; -LocationRequest::LocationRequest(const std::string & action) : - RpcServiceRequest("location", "2015-06-12", action) { -} +LocationRequest::LocationRequest(const std::string &action) + : RpcServiceRequest("location", "2015-06-12", action) {} -LocationRequest::~LocationRequest() { -} +LocationRequest::~LocationRequest() {} diff --git a/core/src/location/model/DescribeEndpointsRequest.cc b/core/src/location/model/DescribeEndpointsRequest.cc index b35710548..b9c112f43 100644 --- a/core/src/location/model/DescribeEndpointsRequest.cc +++ b/core/src/location/model/DescribeEndpointsRequest.cc @@ -19,33 +19,27 @@ using namespace AlibabaCloud::Location; using namespace AlibabaCloud::Location::Model; -DescribeEndpointsRequest::DescribeEndpointsRequest() : - LocationRequest("DescribeEndpoints") -{} +DescribeEndpointsRequest::DescribeEndpointsRequest() + : LocationRequest("DescribeEndpoints") {} -DescribeEndpointsRequest::~DescribeEndpointsRequest() -{} +DescribeEndpointsRequest::~DescribeEndpointsRequest() {} -std::string DescribeEndpointsRequest::serviceCode()const { +std::string DescribeEndpointsRequest::serviceCode() const { return parameter("ServiceCode"); } -void DescribeEndpointsRequest::setServiceCode(const std::string & serviceCode) { +void DescribeEndpointsRequest::setServiceCode(const std::string &serviceCode) { setParameter("ServiceCode", serviceCode); } -std::string DescribeEndpointsRequest::id()const { - return parameter("Id"); -} +std::string DescribeEndpointsRequest::id() const { return parameter("Id"); } -void DescribeEndpointsRequest::setId(const std::string & id) { +void DescribeEndpointsRequest::setId(const std::string &id) { setParameter("Id", id); } -std::string DescribeEndpointsRequest::type()const { - return parameter("Type"); -} +std::string DescribeEndpointsRequest::type() const { return parameter("Type"); } -void DescribeEndpointsRequest::setType(const std::string & type) { +void DescribeEndpointsRequest::setType(const std::string &type) { setParameter("Type", type); } diff --git a/core/src/sts/StsClient.cc b/core/src/sts/StsClient.cc index 61d531bea..9d0e6fb90 100644 --- a/core/src/sts/StsClient.cc +++ b/core/src/sts/StsClient.cc @@ -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 -#include #include +#include +#include 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(credentials), configuration) { -} + const ClientConfiguration &configuration) + : RpcServiceClient(SERVICE_NAME, + std::make_shared(credentials), + configuration) {} StsClient::StsClient( - const std::shared_ptr& credentialsProvider, - const ClientConfiguration & configuration) : - RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) { -} + const std::shared_ptr &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(accessKeyId, - accessKeySecret), configuration) { -} +StsClient::StsClient(const std::string &accessKeyId, + const std::string &accessKeySecret, + const ClientConfiguration &configuration) + : RpcServiceClient(SERVICE_NAME, + std::make_shared( + accessKeyId, accessKeySecret), + configuration) {} -StsClient::~StsClient() { -} +StsClient::~StsClient() {} -StsClient::AssumeRoleOutcome StsClient::assumeRole( - const Model::AssumeRoleRequest &request)const { +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& context) const { +void StsClient::assumeRoleAsync( + const Model::AssumeRoleRequest &request, + const AssumeRoleAsyncHandler &handler, + const std::shared_ptr &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>( - [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& context) const { +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); }; @@ -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>( - [this, request]() { - return this->getCallerIdentity(request); - }); + [this, request]() { return this->getCallerIdentity(request); }); asyncExecute(new Runnable([task]() { (*task)(); })); return task->get_future(); diff --git a/core/src/sts/StsRequest.cc b/core/src/sts/StsRequest.cc index 3128957d6..28772ba5b 100644 --- a/core/src/sts/StsRequest.cc +++ b/core/src/sts/StsRequest.cc @@ -1,27 +1,25 @@ /* -* 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 using namespace AlibabaCloud; using namespace AlibabaCloud::Sts; -StsRequest::StsRequest(const std::string & action) : - RpcServiceRequest("sts", "2015-04-01", action) { -} +StsRequest::StsRequest(const std::string &action) + : RpcServiceRequest("sts", "2015-04-01", action) {} -StsRequest::~StsRequest() { -} +StsRequest::~StsRequest() {} diff --git a/core/src/sts/model/AssumeRoleRequest.cc b/core/src/sts/model/AssumeRoleRequest.cc index 9a579ddf6..232898367 100644 --- a/core/src/sts/model/AssumeRoleRequest.cc +++ b/core/src/sts/model/AssumeRoleRequest.cc @@ -1,18 +1,18 @@ /* -* 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 @@ -20,27 +20,21 @@ using namespace AlibabaCloud::Sts; using namespace AlibabaCloud::Sts::Model; -AssumeRoleRequest::AssumeRoleRequest() : - StsRequest("AssumeRole") { +AssumeRoleRequest::AssumeRoleRequest() : StsRequest("AssumeRole") { setRoleArn(""); setRoleSessionName(""); setDurationSeconds(3600); } -AssumeRoleRequest::~AssumeRoleRequest() { -} +AssumeRoleRequest::~AssumeRoleRequest() {} int AssumeRoleRequest::durationSeconds() const { return std::stoi(parameter("DurationSeconds")); } -std::string AssumeRoleRequest::policy() const { - return parameter("Policy"); -} +std::string AssumeRoleRequest::policy() const { return parameter("Policy"); } -std::string AssumeRoleRequest::roleArn() const { - return parameter("RoleArn"); -} +std::string AssumeRoleRequest::roleArn() const { return parameter("RoleArn"); } std::string AssumeRoleRequest::roleSessionName() const { return parameter("RoleSessionName"); @@ -50,15 +44,14 @@ void AssumeRoleRequest::setDurationSeconds(int durationSeconds) { setParameter("DurationSeconds", std::to_string(durationSeconds)); } -void AssumeRoleRequest::setPolicy(const std::string & policy) { +void AssumeRoleRequest::setPolicy(const std::string &policy) { setParameter("Policy", policy); } -void AssumeRoleRequest::setRoleArn(const std::string & roleArn) { +void AssumeRoleRequest::setRoleArn(const std::string &roleArn) { setParameter("RoleArn", roleArn); } -void AssumeRoleRequest::setRoleSessionName( - const std::string & roleSessionName) { +void AssumeRoleRequest::setRoleSessionName(const std::string &roleSessionName) { setParameter("RoleSessionName", roleSessionName); } diff --git a/core/src/sts/model/AssumeRoleResult.cc b/core/src/sts/model/AssumeRoleResult.cc index cf1811f7e..42349780a 100644 --- a/core/src/sts/model/AssumeRoleResult.cc +++ b/core/src/sts/model/AssumeRoleResult.cc @@ -25,25 +25,21 @@ AssumeRoleResult::AssumeRoleResult() : ServiceResult(), assumedRoleUser_(), credentials_() {} AssumeRoleResult::AssumeRoleResult(const std::string &payload) - : ServiceResult(), assumedRoleUser_(), credentials_() -{ + : ServiceResult(), assumedRoleUser_(), credentials_() { parse(payload); } AssumeRoleResult::~AssumeRoleResult() {} -AssumeRoleResult::AssumedRoleUser AssumeRoleResult::assumedRoleUser() const -{ +AssumeRoleResult::AssumedRoleUser AssumeRoleResult::assumedRoleUser() const { return assumedRoleUser_; } -AssumeRoleResult::Credentials AssumeRoleResult::credentials() const -{ +AssumeRoleResult::Credentials AssumeRoleResult::credentials() const { return credentials_; } -void AssumeRoleResult::parse(const std::string &payload) -{ +void AssumeRoleResult::parse(const std::string &payload) { Json::Reader reader; Json::Value value; reader.parse(payload, value); diff --git a/core/src/sts/model/GetCallerIdentityRequest.cc b/core/src/sts/model/GetCallerIdentityRequest.cc index 7c08987ad..1aff84b51 100644 --- a/core/src/sts/model/GetCallerIdentityRequest.cc +++ b/core/src/sts/model/GetCallerIdentityRequest.cc @@ -1,18 +1,18 @@ /* -* 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 @@ -20,9 +20,7 @@ using namespace AlibabaCloud; using namespace AlibabaCloud::Sts; using namespace AlibabaCloud::Sts::Model; -GetCallerIdentityRequest::GetCallerIdentityRequest() : - StsRequest("GetCallerIdentity") { -} +GetCallerIdentityRequest::GetCallerIdentityRequest() + : StsRequest("GetCallerIdentity") {} -GetCallerIdentityRequest::~GetCallerIdentityRequest() { -} +GetCallerIdentityRequest::~GetCallerIdentityRequest() {}