fix most cpplint checkpoint
This commit is contained in:
@@ -14,16 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ALIBABACLOUD_H_
|
||||
#define ALIBABACLOUD_CORE_ALIBABACLOUD_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ALIBABACLOUD_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_ALIBABACLOUD_H_
|
||||
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
ALIBABACLOUD_CORE_EXPORT void InitializeSdk();
|
||||
ALIBABACLOUD_CORE_EXPORT bool IsSdkInitialized();
|
||||
ALIBABACLOUD_CORE_EXPORT void ShutdownSdk();
|
||||
}
|
||||
namespace AlibabaCloud {
|
||||
ALIBABACLOUD_CORE_EXPORT void InitializeSdk();
|
||||
ALIBABACLOUD_CORE_EXPORT bool IsSdkInitialized();
|
||||
ALIBABACLOUD_CORE_EXPORT void ShutdownSdk();
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ALIBABACLOUD_H_
|
||||
|
||||
@@ -14,25 +14,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_
|
||||
#define ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT AsyncCallerContext
|
||||
{
|
||||
public:
|
||||
AsyncCallerContext();
|
||||
explicit AsyncCallerContext(const std::string &uuid);
|
||||
virtual ~AsyncCallerContext();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT AsyncCallerContext {
|
||||
public:
|
||||
AsyncCallerContext();
|
||||
explicit AsyncCallerContext(const std::string &uuid);
|
||||
virtual ~AsyncCallerContext();
|
||||
|
||||
std::string uuid()const;
|
||||
void setUuid(const std::string &uuid);
|
||||
private:
|
||||
std::string uuid_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
std::string uuid()const;
|
||||
void setUuid(const std::string &uuid);
|
||||
|
||||
private:
|
||||
std::string uuid_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_
|
||||
#define ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -24,26 +24,25 @@
|
||||
#include "NetworkProxy.h"
|
||||
#include "Signer.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT ClientConfiguration
|
||||
{
|
||||
public:
|
||||
explicit ClientConfiguration(const std::string ®ionId = "cn-hangzhou",
|
||||
const NetworkProxy &proxy = NetworkProxy());
|
||||
~ClientConfiguration();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT ClientConfiguration {
|
||||
public:
|
||||
explicit ClientConfiguration(const std::string ®ionId = "cn-hangzhou",
|
||||
const NetworkProxy &proxy = NetworkProxy());
|
||||
~ClientConfiguration();
|
||||
|
||||
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);
|
||||
private:
|
||||
std::string endpoint_;
|
||||
NetworkProxy proxy_;
|
||||
std::string regionId_;
|
||||
};
|
||||
}
|
||||
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);
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_
|
||||
private:
|
||||
std::string endpoint_;
|
||||
NetworkProxy proxy_;
|
||||
std::string regionId_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_COMMONCLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_COMMONCLIENT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONCLIENT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONCLIENT_H_
|
||||
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "AsyncCallerContext.h"
|
||||
#include "ClientConfiguration.h"
|
||||
#include "CoreExport.h"
|
||||
@@ -26,36 +28,50 @@
|
||||
#include "CommonResponse.h"
|
||||
#include "CredentialsProvider.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT CommonClient : public CoreClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, CommonResponse> CommonResponseOutcome;
|
||||
typedef std::future<CommonResponseOutcome> CommonResponseOutcomeCallable;
|
||||
typedef std::function<void(const CommonClient*, const CommonRequest&, const CommonResponseOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CommonResponseAsyncHandler;
|
||||
typedef Outcome<Error, std::string> JsonOutcome;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT CommonClient : public CoreClient {
|
||||
public:
|
||||
typedef Outcome<Error, CommonResponse> CommonResponseOutcome;
|
||||
typedef std::future<CommonResponseOutcome> CommonResponseOutcomeCallable;
|
||||
typedef std::function<void(const CommonClient*, const CommonRequest&,
|
||||
const CommonResponseOutcome&,
|
||||
const std::shared_ptr<const AsyncCallerContext>&)>
|
||||
CommonResponseAsyncHandler;
|
||||
typedef Outcome<Error, std::string> JsonOutcome;
|
||||
|
||||
CommonClient(const Credentials &credentials, const ClientConfiguration &configuration);
|
||||
CommonClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||
CommonClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
|
||||
~CommonClient();
|
||||
CommonClient(const Credentials &credentials,
|
||||
const ClientConfiguration &configuration);
|
||||
CommonClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration);
|
||||
CommonClient(const std::string &accessKeyId,
|
||||
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<const AsyncCallerContext>& context = nullptr) const;
|
||||
CommonResponseOutcomeCallable commonResponseCallable(const CommonRequest& request) const;
|
||||
CommonResponseOutcome commonResponse(const CommonRequest &request) const;
|
||||
void commonResponseAsync(const CommonRequest& request,
|
||||
const CommonResponseAsyncHandler& handler,
|
||||
const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
CommonResponseOutcomeCallable commonResponseCallable(
|
||||
const CommonRequest& request) const;
|
||||
|
||||
protected:
|
||||
virtual 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:
|
||||
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;
|
||||
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
std::shared_ptr<Signer> signer_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_COMMONCLIENT_H_
|
||||
private:
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
std::shared_ptr<Signer> signer_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONCLIENT_H_
|
||||
|
||||
@@ -14,53 +14,53 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_COMMONREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_COMMONREQUEST_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONREQUEST_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
#include "ServiceRequest.h"
|
||||
#include "HttpRequest.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT CommonRequest : public ServiceRequest
|
||||
{
|
||||
public:
|
||||
enum RequestPattern
|
||||
{
|
||||
RpcPattern,
|
||||
RoaPattern
|
||||
};
|
||||
|
||||
explicit CommonRequest(RequestPattern pattern = RpcPattern);
|
||||
~CommonRequest();
|
||||
|
||||
std::string domain()const;
|
||||
ParameterValueType headerParameter(const ParameterNameType &name)const;
|
||||
ParameterCollection headerParameters()const;
|
||||
HttpRequest::Method httpMethod()const;
|
||||
ParameterValueType queryParameter(const ParameterNameType &name)const;
|
||||
ParameterCollection queryParameters()const;
|
||||
using ServiceRequest::setContent;
|
||||
void setDomain(const std::string &domain);
|
||||
void setHeaderParameter(const ParameterNameType &name, const ParameterValueType &value);
|
||||
void setHttpMethod(HttpRequest::Method method);
|
||||
void setQueryParameter(const ParameterNameType &name, const ParameterValueType &value);
|
||||
using ServiceRequest::setResourcePath;
|
||||
void setRequestPattern(RequestPattern pattern);
|
||||
using ServiceRequest::setVersion;
|
||||
using ServiceRequest::setScheme;
|
||||
RequestPattern requestPattern()const;
|
||||
protected:
|
||||
using ServiceRequest::product;
|
||||
|
||||
private:
|
||||
std::string domain_;
|
||||
RequestPattern requestPattern_;
|
||||
ParameterCollection queryParams_;
|
||||
ParameterCollection headerParams_;
|
||||
HttpRequest::Method httpMethod_;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT CommonRequest : public ServiceRequest {
|
||||
public:
|
||||
enum RequestPattern {
|
||||
RpcPattern,
|
||||
RoaPattern
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_COMMONREQUEST_H_
|
||||
|
||||
explicit CommonRequest(RequestPattern pattern = RpcPattern);
|
||||
~CommonRequest();
|
||||
|
||||
std::string domain() const;
|
||||
ParameterValueType headerParameter(const ParameterNameType &name) const;
|
||||
ParameterCollection headerParameters() const;
|
||||
HttpRequest::Method httpMethod() const;
|
||||
ParameterValueType queryParameter(const ParameterNameType &name) const;
|
||||
ParameterCollection queryParameters() const;
|
||||
using ServiceRequest::setContent;
|
||||
void setDomain(const std::string &domain);
|
||||
void setHeaderParameter(const ParameterNameType &name,
|
||||
const ParameterValueType &value);
|
||||
void setHttpMethod(HttpRequest::Method method);
|
||||
void setQueryParameter(const ParameterNameType &name,
|
||||
const ParameterValueType &value);
|
||||
using ServiceRequest::setResourcePath;
|
||||
void setRequestPattern(RequestPattern pattern);
|
||||
using ServiceRequest::setVersion;
|
||||
using ServiceRequest::setScheme;
|
||||
RequestPattern requestPattern() const;
|
||||
|
||||
protected:
|
||||
using ServiceRequest::product;
|
||||
|
||||
private:
|
||||
std::string domain_;
|
||||
RequestPattern requestPattern_;
|
||||
ParameterCollection queryParams_;
|
||||
ParameterCollection headerParams_;
|
||||
HttpRequest::Method httpMethod_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONREQUEST_H_
|
||||
|
||||
@@ -14,25 +14,23 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_COMMONRESPONSE_H_
|
||||
#define ALIBABACLOUD_CORE_COMMONRESPONSE_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONRESPONSE_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONRESPONSE_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT CommonResponse
|
||||
{
|
||||
public:
|
||||
CommonResponse();
|
||||
explicit CommonResponse(const std::string &payload);
|
||||
~CommonResponse();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT CommonResponse {
|
||||
public:
|
||||
CommonResponse();
|
||||
explicit CommonResponse(const std::string &payload);
|
||||
~CommonResponse();
|
||||
|
||||
std::string payload()const;
|
||||
private:
|
||||
std::string payload_;
|
||||
std::string payload()const;
|
||||
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_COMMONRESPONSE_H_
|
||||
private:
|
||||
std::string payload_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COMMONRESPONSE_H_
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_CORECLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_CORECLIENT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_CORECLIENT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_CORECLIENT_H_
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "ClientConfiguration.h"
|
||||
#include "CoreExport.h"
|
||||
#include "HttpClient.h"
|
||||
@@ -28,27 +29,31 @@
|
||||
#include "ServiceRequest.h"
|
||||
#include "Runnable.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT CoreClient
|
||||
{
|
||||
public:
|
||||
CoreClient(const std::string & servicename, const ClientConfiguration &configuration);
|
||||
virtual ~CoreClient();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT CoreClient {
|
||||
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;
|
||||
private:
|
||||
std::string serviceName_;
|
||||
ClientConfiguration configuration_;
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
HttpClient *httpClient_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
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;
|
||||
|
||||
private:
|
||||
std::string serviceName_;
|
||||
ClientConfiguration configuration_;
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
HttpClient *httpClient_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CORECLIENT_H_
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_COREEXPORT_H_
|
||||
#define ALIBABACLOUD_CORE_COREEXPORT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_COREEXPORT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_COREEXPORT_H_
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
@@ -29,4 +29,4 @@
|
||||
# define ALIBABACLOUD_CORE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_COREEXPORT_H_
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_COREEXPORT_H_
|
||||
|
||||
@@ -14,34 +14,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_CREDENTIAL_H_
|
||||
#define ALIBABACLOUD_CORE_CREDENTIAL_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALS_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALS_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT Credentials
|
||||
{
|
||||
public:
|
||||
Credentials(const std::string &accessKeyId,
|
||||
const std::string &accessKeySecret,
|
||||
const std::string &sessionToken="");
|
||||
~Credentials();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT Credentials {
|
||||
public:
|
||||
Credentials(const std::string &accessKeyId,
|
||||
const std::string &accessKeySecret,
|
||||
const std::string &sessionToken = "");
|
||||
~Credentials();
|
||||
|
||||
std::string accessKeyId () const;
|
||||
std::string accessKeySecret () const;
|
||||
void setAccessKeyId(const std::string &accessKeyId);
|
||||
void setAccessKeySecret(const std::string &accessKeySecret);
|
||||
void setSessionToken (const std::string &sessionToken);
|
||||
std::string sessionToken () const;
|
||||
std::string accessKeyId() const;
|
||||
std::string accessKeySecret() const;
|
||||
void setAccessKeyId(const std::string &accessKeyId);
|
||||
void setAccessKeySecret(const std::string &accessKeySecret);
|
||||
void setSessionToken(const std::string &sessionToken);
|
||||
std::string sessionToken() const;
|
||||
|
||||
private:
|
||||
std::string accessKeyId_;
|
||||
std::string accessKeySecret_;
|
||||
std::string sessionToken_;
|
||||
};
|
||||
}
|
||||
private:
|
||||
std::string accessKeyId_;
|
||||
std::string accessKeySecret_;
|
||||
std::string sessionToken_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_CREDENTIAL_H_
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALS_H_
|
||||
|
||||
@@ -14,23 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_CREDENTIALSPROVIDER_H_
|
||||
#define ALIBABACLOUD_CORE_CREDENTIALSPROVIDER_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALSPROVIDER_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALSPROVIDER_H_
|
||||
|
||||
#include "CoreExport.h"
|
||||
#include "Credentials.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT CredentialsProvider
|
||||
{
|
||||
public:
|
||||
CredentialsProvider() = default;
|
||||
virtual ~CredentialsProvider() = default;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT CredentialsProvider {
|
||||
public:
|
||||
CredentialsProvider() = default;
|
||||
virtual ~CredentialsProvider() = default;
|
||||
virtual Credentials getCredentials() = 0;
|
||||
|
||||
virtual Credentials getCredentials() = 0;
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
private:
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_CREDENTIALSPROVIDER_H_
|
||||
|
||||
@@ -14,65 +14,67 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_
|
||||
#define ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_
|
||||
|
||||
#include <alibabacloud/core/location/LocationClient.h>
|
||||
#include <alibabacloud/core/CoreClient.h>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <alibabacloud/core/location/LocationClient.h>
|
||||
#include <alibabacloud/core/CoreClient.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT EndpointProvider : public Location::LocationClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, std::string> EndpointOutcome;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT EndpointProvider :
|
||||
public Location::LocationClient {
|
||||
public:
|
||||
typedef Outcome<Error, std::string> EndpointOutcome;
|
||||
|
||||
EndpointProvider(const std::shared_ptr<Location::LocationClient>& locationClient,
|
||||
const std::string regionId,
|
||||
const std::string product,
|
||||
const std::string serviceCode = std::string(),
|
||||
int durationSeconds = 3600);
|
||||
EndpointProvider(
|
||||
const std::shared_ptr<Location::LocationClient>& 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();
|
||||
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:
|
||||
struct Product
|
||||
{
|
||||
std::string code;
|
||||
std::string locationServiceCode;
|
||||
std::string documentId;
|
||||
std::map<std::string, std::string> regionalEndpoints;
|
||||
std::string globalEndpoint;
|
||||
std::string regionalEndpointPattern;
|
||||
};
|
||||
EndpointOutcome getEndpoint();
|
||||
using LocationClient::describeEndpoints;
|
||||
|
||||
EndpointOutcome loadRemoteEndpoint();
|
||||
bool checkExpiry()const;
|
||||
bool loadInternalProductsInfo();
|
||||
std::string internalEndpoint(const std::string regionId, const std::string product);
|
||||
|
||||
std::mutex cachedMutex_;
|
||||
std::string cachedEndpoint_;
|
||||
int durationSeconds_;
|
||||
std::chrono::system_clock::time_point expiry_;
|
||||
std::string regionId_;
|
||||
std::string product_;
|
||||
std::string serviceCode_;
|
||||
std::list<Product> internalProductsInfo_;
|
||||
private:
|
||||
struct Product {
|
||||
std::string code;
|
||||
std::string locationServiceCode;
|
||||
std::string documentId;
|
||||
std::map<std::string, std::string> regionalEndpoints;
|
||||
std::string globalEndpoint;
|
||||
std::string regionalEndpointPattern;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
EndpointOutcome loadRemoteEndpoint();
|
||||
bool checkExpiry()const;
|
||||
bool loadInternalProductsInfo();
|
||||
std::string internalEndpoint(const std::string regionId,
|
||||
const std::string product);
|
||||
|
||||
std::mutex cachedMutex_;
|
||||
std::string cachedEndpoint_;
|
||||
int durationSeconds_;
|
||||
std::chrono::system_clock::time_point expiry_;
|
||||
std::string regionId_;
|
||||
std::string product_;
|
||||
std::string serviceCode_;
|
||||
std::list<Product> internalProductsInfo_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_
|
||||
|
||||
@@ -14,38 +14,37 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ERROR_H_
|
||||
#define ALIBABACLOUD_CORE_ERROR_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ERROR_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_ERROR_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT Error
|
||||
{
|
||||
public:
|
||||
Error() = default;
|
||||
Error(std::string code, const std::string message);
|
||||
~Error() = default;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT Error {
|
||||
public:
|
||||
Error() = default;
|
||||
Error(std::string code, const std::string message);
|
||||
~Error() = default;
|
||||
|
||||
std::string errorCode()const;
|
||||
std::string errorMessage() const;
|
||||
std::string host() const;
|
||||
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);
|
||||
private:
|
||||
std::string errorCode_;
|
||||
std::string message_;
|
||||
std::string host_;
|
||||
std::string requestId_;
|
||||
std::string detail_;
|
||||
};
|
||||
}
|
||||
std::string errorCode() const;
|
||||
std::string errorMessage() const;
|
||||
std::string host() const;
|
||||
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);
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_ERROR_H_
|
||||
private:
|
||||
std::string errorCode_;
|
||||
std::string message_;
|
||||
std::string host_;
|
||||
std::string requestId_;
|
||||
std::string detail_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ERROR_H_
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_GLOBAL_H_
|
||||
#define ALIBABACLOUD_CORE_GLOBAL_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_GLOBAL_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_GLOBAL_H_
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# ifdef _MSC_VER
|
||||
# pragma warning(disable : 4251)
|
||||
# endif // _MSC_VER
|
||||
# endif // _MSC_VER
|
||||
# define ALIBABACLOUD_DECL_EXPORT __declspec(dllexport)
|
||||
# define ALIBABACLOUD_DECL_IMPORT __declspec(dllimport)
|
||||
#elif defined(__linux__)
|
||||
@@ -38,4 +38,4 @@
|
||||
# define ALIBABACLOUD_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_GLOBAL_H_
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_GLOBAL_H_
|
||||
|
||||
@@ -14,21 +14,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_
|
||||
#define ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_
|
||||
|
||||
#include "Signer.h"
|
||||
#include <string>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT HmacSha1Signer : public Signer
|
||||
{
|
||||
public:
|
||||
HmacSha1Signer();
|
||||
~HmacSha1Signer();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT HmacSha1Signer : public Signer {
|
||||
public:
|
||||
HmacSha1Signer();
|
||||
~HmacSha1Signer();
|
||||
|
||||
virtual std::string generate(const std::string &src, const std::string &secret)const override;
|
||||
};
|
||||
}
|
||||
std::string generate(const std::string &src,
|
||||
const std::string &secret) const override;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HTTPCLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_HTTPCLIENT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPCLIENT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPCLIENT_H_
|
||||
|
||||
#include <alibabacloud/core/HttpRequest.h>
|
||||
#include <alibabacloud/core/HttpResponse.h>
|
||||
@@ -23,21 +23,20 @@
|
||||
#include <alibabacloud/core/Outcome.h>
|
||||
#include <alibabacloud/core/Error.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class HttpClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, HttpResponse> HttpResponseOutcome;
|
||||
namespace AlibabaCloud {
|
||||
class HttpClient {
|
||||
public:
|
||||
typedef Outcome<Error, HttpResponse> HttpResponseOutcome;
|
||||
|
||||
HttpClient();
|
||||
virtual ~HttpClient();
|
||||
HttpClient();
|
||||
virtual ~HttpClient();
|
||||
|
||||
virtual HttpResponseOutcome makeRequest(const HttpRequest &request) = 0;
|
||||
NetworkProxy proxy()const;
|
||||
void setProxy(const NetworkProxy &proxy);
|
||||
private:
|
||||
NetworkProxy proxy_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
virtual HttpResponseOutcome makeRequest(const HttpRequest &request) = 0;
|
||||
NetworkProxy proxy()const;
|
||||
void setProxy(const NetworkProxy &proxy);
|
||||
|
||||
private:
|
||||
NetworkProxy proxy_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPCLIENT_H_
|
||||
|
||||
@@ -14,69 +14,69 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HTTPMESSAGE_H_
|
||||
#define ALIBABACLOUD_CORE_HTTPMESSAGE_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPMESSAGE_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPMESSAGE_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT HttpMessage
|
||||
{
|
||||
private:
|
||||
struct ALIBABACLOUD_CORE_EXPORT nocaseLess
|
||||
{
|
||||
bool operator() (const std::string & s1, const std::string & s2) const;
|
||||
};
|
||||
public:
|
||||
enum KnownHeader
|
||||
{
|
||||
Accept,
|
||||
AcceptCharset,
|
||||
AcceptEncoding,
|
||||
AcceptLanguage,
|
||||
Authorization,
|
||||
Connection,
|
||||
ContentLength,
|
||||
ContentMD5,
|
||||
ContentType,
|
||||
Date,
|
||||
Host,
|
||||
Server,
|
||||
UserAgent
|
||||
};
|
||||
|
||||
typedef std::string HeaderNameType;
|
||||
typedef std::string HeaderValueType;
|
||||
typedef std::map<HeaderNameType, HeaderValueType, nocaseLess> HeaderCollection;
|
||||
|
||||
HttpMessage(const HttpMessage &other);
|
||||
HttpMessage(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;
|
||||
HeaderValueType header(const HeaderNameType &name)const;
|
||||
HeaderValueType header(KnownHeader header)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:
|
||||
HttpMessage();
|
||||
private:
|
||||
char *body_;
|
||||
size_t bodySize_;
|
||||
HeaderCollection headers_;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT HttpMessage {
|
||||
private:
|
||||
struct ALIBABACLOUD_CORE_EXPORT nocaseLess {
|
||||
bool operator() (const std::string & s1, const std::string & s2) const;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_HTTPMESSAGE_H_
|
||||
|
||||
public:
|
||||
enum KnownHeader {
|
||||
Accept,
|
||||
AcceptCharset,
|
||||
AcceptEncoding,
|
||||
AcceptLanguage,
|
||||
Authorization,
|
||||
Connection,
|
||||
ContentLength,
|
||||
ContentMD5,
|
||||
ContentType,
|
||||
Date,
|
||||
Host,
|
||||
Server,
|
||||
UserAgent
|
||||
};
|
||||
|
||||
typedef std::string HeaderNameType;
|
||||
typedef std::string HeaderValueType;
|
||||
typedef std::map<HeaderNameType, HeaderValueType, nocaseLess>
|
||||
HeaderCollection;
|
||||
|
||||
HttpMessage(const HttpMessage &other);
|
||||
HttpMessage(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;
|
||||
HeaderValueType header(const HeaderNameType &name) const;
|
||||
HeaderValueType header(KnownHeader header) 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:
|
||||
HttpMessage();
|
||||
|
||||
private:
|
||||
char *body_;
|
||||
size_t bodySize_;
|
||||
HeaderCollection headers_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPMESSAGE_H_
|
||||
|
||||
@@ -14,40 +14,38 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HTTPREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_HTTPREQUEST_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPREQUEST_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include "HttpMessage.h"
|
||||
#include "Url.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT HttpRequest : public HttpMessage
|
||||
{
|
||||
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;
|
||||
void setMethod(Method method);
|
||||
void setUrl(const Url &url);
|
||||
Url url()const;
|
||||
private:
|
||||
Method method_;
|
||||
Url url_;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT HttpRequest : public HttpMessage {
|
||||
public:
|
||||
enum Method {
|
||||
Get,
|
||||
Head,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Connect,
|
||||
Options,
|
||||
Patch,
|
||||
Trace
|
||||
};
|
||||
}
|
||||
#endif
|
||||
explicit HttpRequest(const Url &url = Url(), Method method = Get);
|
||||
~HttpRequest();
|
||||
|
||||
Method method()const;
|
||||
void setMethod(Method method);
|
||||
void setUrl(const Url &url);
|
||||
Url url()const;
|
||||
|
||||
private:
|
||||
Method method_;
|
||||
Url url_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPREQUEST_H_
|
||||
|
||||
@@ -14,30 +14,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HTTPRESPONSE_H_
|
||||
#define ALIBABACLOUD_CORE_HTTPRESPONSE_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPRESPONSE_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPRESPONSE_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
#include "HttpMessage.h"
|
||||
#include "HttpRequest.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT HttpResponse : public HttpMessage
|
||||
{
|
||||
public:
|
||||
HttpResponse();
|
||||
explicit HttpResponse(const HttpRequest & request);
|
||||
~HttpResponse();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT HttpResponse : public HttpMessage {
|
||||
public:
|
||||
HttpResponse();
|
||||
explicit HttpResponse(const HttpRequest & request);
|
||||
~HttpResponse();
|
||||
|
||||
HttpRequest request()const;
|
||||
void setStatusCode(int code);
|
||||
int statusCode()const;
|
||||
private:
|
||||
int statusCode_;
|
||||
HttpRequest request_;
|
||||
};
|
||||
}
|
||||
HttpRequest request()const;
|
||||
void setStatusCode(int code);
|
||||
int statusCode()const;
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_HTTPRESPONSE_H_
|
||||
private:
|
||||
int statusCode_;
|
||||
HttpRequest request_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_HTTPRESPONSE_H_
|
||||
|
||||
@@ -14,21 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_
|
||||
#define ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_
|
||||
|
||||
#include "BasicSessionCredentials.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class InstanceProfileCredentials : public BasicSessionCredentials
|
||||
{
|
||||
public:
|
||||
InstanceProfileCredentials();
|
||||
~InstanceProfileCredentials();
|
||||
namespace AlibabaCloud {
|
||||
class InstanceProfileCredentials : public BasicSessionCredentials {
|
||||
public:
|
||||
InstanceProfileCredentials();
|
||||
~InstanceProfileCredentials();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_
|
||||
private:
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_
|
||||
#define ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_
|
||||
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
@@ -25,27 +25,28 @@
|
||||
#include "Credentials.h"
|
||||
#include "../src/EcsMetadataFetcher.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT InstanceProfileCredentialsProvider : public CredentialsProvider, public EcsMetadataFetcher
|
||||
{
|
||||
public:
|
||||
InstanceProfileCredentialsProvider(const std::string &roleName, int durationSeconds = 3600);
|
||||
~InstanceProfileCredentialsProvider();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT InstanceProfileCredentialsProvider :
|
||||
public CredentialsProvider, public EcsMetadataFetcher {
|
||||
public:
|
||||
InstanceProfileCredentialsProvider(const std::string &roleName,
|
||||
int durationSeconds = 3600);
|
||||
~InstanceProfileCredentialsProvider();
|
||||
|
||||
std::string roleName()const;
|
||||
virtual Credentials getCredentials() override;
|
||||
using EcsMetadataFetcher::roleName;
|
||||
using EcsMetadataFetcher::setRoleName;
|
||||
using EcsMetadataFetcher::getMetadata;
|
||||
private:
|
||||
void loadCredentials();
|
||||
bool checkExpiry()const;
|
||||
std::string roleName()const;
|
||||
Credentials getCredentials() override;
|
||||
using EcsMetadataFetcher::roleName;
|
||||
using EcsMetadataFetcher::setRoleName;
|
||||
using EcsMetadataFetcher::getMetadata;
|
||||
|
||||
std::mutex cachedMutex_;
|
||||
Credentials cachedCredentials_;
|
||||
int durationSeconds_;
|
||||
std::chrono::system_clock::time_point expiry_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
private:
|
||||
void loadCredentials();
|
||||
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_
|
||||
|
||||
@@ -14,46 +14,44 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_NETWORKPROXY_H_
|
||||
#define ALIBABACLOUD_CORE_NETWORKPROXY_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_NETWORKPROXY_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_NETWORKPROXY_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
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 = "");
|
||||
~NetworkProxy();
|
||||
|
||||
std::string hostName() const;
|
||||
std::string password() const;
|
||||
uint16_t port() const;
|
||||
void setHostName(const std::string &hostName);
|
||||
void setPassword(const std::string &password);
|
||||
void setPort(uint16_t port);
|
||||
void setType(Type type);
|
||||
void setUser(const std::string &user);
|
||||
Type type() const;
|
||||
std::string user() const;
|
||||
private:
|
||||
std::string hostName_;
|
||||
std::string password_;
|
||||
uint16_t port_;
|
||||
Type type_;
|
||||
std::string user_;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT NetworkProxy {
|
||||
public:
|
||||
enum Type {
|
||||
None = 0,
|
||||
Http,
|
||||
Socks5
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_NETWORKPROXY_H_
|
||||
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;
|
||||
uint16_t port() const;
|
||||
void setHostName(const std::string &hostName);
|
||||
void setPassword(const std::string &password);
|
||||
void setPort(uint16_t port);
|
||||
void setType(Type type);
|
||||
void setUser(const std::string &user);
|
||||
Type type() const;
|
||||
std::string user() const;
|
||||
|
||||
private:
|
||||
std::string hostName_;
|
||||
std::string password_;
|
||||
uint16_t port_;
|
||||
Type type_;
|
||||
std::string user_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_NETWORKPROXY_H_
|
||||
|
||||
@@ -14,59 +14,54 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_OUTCOME_H_
|
||||
#define ALIBABACLOUD_CORE_OUTCOME_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_OUTCOME_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_OUTCOME_H_
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
template<typename E, typename R>
|
||||
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);
|
||||
namespace AlibabaCloud {
|
||||
template<typename E, typename R>
|
||||
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_;
|
||||
r_ = other.r_;
|
||||
}
|
||||
Outcome & operator=(const Outcome &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
success_ = other.success_;
|
||||
e_ = other.e_;
|
||||
r_ = other.r_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
Outcome & operator=(Outcome &&other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
success_ = other.success_;
|
||||
r_ = other.r_;
|
||||
e_ = other.e_;
|
||||
}
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
Outcome & operator=(Outcome &&other) {
|
||||
if (this != &other) {
|
||||
success_ = other.success_;
|
||||
r_ = other.r_;
|
||||
e_ = other.e_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool isSuccess()const { return success_; }
|
||||
E error()const { return e_; }
|
||||
R result()const { return r_; }
|
||||
private:
|
||||
bool success_;
|
||||
E e_;
|
||||
R r_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_OUTCOME_H_
|
||||
bool isSuccess()const { return success_; }
|
||||
E error()const { return e_; }
|
||||
R result()const { return r_; }
|
||||
|
||||
private:
|
||||
bool success_;
|
||||
E e_;
|
||||
R r_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_OUTCOME_H_
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ROASERVICECLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_ROASERVICECLIENT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICECLIENT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICECLIENT_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -26,26 +26,31 @@
|
||||
#include "HttpRequest.h"
|
||||
#include "RoaServiceRequest.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class RoaErrorMarshaller;
|
||||
class ALIBABACLOUD_CORE_EXPORT RoaServiceClient : public CoreClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, std::string> JsonOutcome;
|
||||
namespace AlibabaCloud {
|
||||
class RoaErrorMarshaller;
|
||||
class ALIBABACLOUD_CORE_EXPORT RoaServiceClient : public CoreClient {
|
||||
public:
|
||||
typedef Outcome<Error, std::string> JsonOutcome;
|
||||
|
||||
RoaServiceClient(const std::string & servicename, const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration,
|
||||
const std::shared_ptr<Signer> &signer = std::make_shared<HmacSha1Signer>());
|
||||
virtual ~RoaServiceClient();
|
||||
RoaServiceClient(const std::string & servicename,
|
||||
const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration,
|
||||
const std::shared_ptr<Signer> &signer =
|
||||
std::make_shared<HmacSha1Signer>());
|
||||
virtual ~RoaServiceClient();
|
||||
|
||||
protected:
|
||||
JsonOutcome makeRequest(const std::string &endpoint, const RoaServiceRequest &msg, HttpRequest::Method method = HttpRequest::Method::Get)const;
|
||||
virtual 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:
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
std::shared_ptr<Signer> signer_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_ROASERVICECLIENT_H_
|
||||
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:
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
std::shared_ptr<Signer> signer_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICECLIENT_H_
|
||||
|
||||
@@ -14,22 +14,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_
|
||||
|
||||
#include "ServiceRequest.h"
|
||||
#include <string>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT RoaServiceRequest : public ServiceRequest
|
||||
{
|
||||
public:
|
||||
RoaServiceRequest(const std::string &product, const std::string &version);
|
||||
virtual ~RoaServiceRequest();
|
||||
using ServiceRequest::setParameter;
|
||||
using ServiceRequest::setContent;
|
||||
using ServiceRequest::parameter;
|
||||
using ServiceRequest::setScheme;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT RoaServiceRequest : public ServiceRequest {
|
||||
public:
|
||||
RoaServiceRequest(const std::string &product, const std::string &version);
|
||||
virtual ~RoaServiceRequest();
|
||||
using ServiceRequest::setParameter;
|
||||
using ServiceRequest::setContent;
|
||||
using ServiceRequest::parameter;
|
||||
using ServiceRequest::setScheme;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -27,34 +27,38 @@
|
||||
#include "RpcServiceRequest.h"
|
||||
#include "Outcome.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class RpcErrorMarshaller;
|
||||
class RpcServiceRequest;
|
||||
class ALIBABACLOUD_CORE_EXPORT RpcServiceClient : public CoreClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, std::string> JsonOutcome;
|
||||
namespace AlibabaCloud {
|
||||
class RpcErrorMarshaller;
|
||||
class RpcServiceRequest;
|
||||
class ALIBABACLOUD_CORE_EXPORT RpcServiceClient : public CoreClient {
|
||||
public:
|
||||
typedef Outcome<Error, std::string> JsonOutcome;
|
||||
|
||||
RpcServiceClient(const std::string & servicename, const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration,
|
||||
const std::shared_ptr<Signer> &signer = std::make_shared<HmacSha1Signer>());
|
||||
virtual ~RpcServiceClient();
|
||||
RpcServiceClient(const std::string & servicename,
|
||||
const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration,
|
||||
const std::shared_ptr<Signer> &signer =
|
||||
std::make_shared<HmacSha1Signer>());
|
||||
virtual ~RpcServiceClient();
|
||||
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider() {
|
||||
return credentialsProvider_;
|
||||
}
|
||||
using CoreClient::configuration;
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider() {
|
||||
return credentialsProvider_;
|
||||
}
|
||||
using CoreClient::configuration;
|
||||
using CoreClient::AttemptRequest;
|
||||
|
||||
using CoreClient::AttemptRequest;
|
||||
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;
|
||||
virtual 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:
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
std::shared_ptr<Signer> signer_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_
|
||||
private:
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
std::shared_ptr<Signer> signer_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_
|
||||
|
||||
@@ -14,24 +14,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_
|
||||
|
||||
#include "ServiceRequest.h"
|
||||
#include <string>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT RpcServiceRequest : public ServiceRequest
|
||||
{
|
||||
public:
|
||||
RpcServiceRequest(const std::string &product, const std::string &version, const std::string & action);
|
||||
virtual ~RpcServiceRequest();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT RpcServiceRequest : public ServiceRequest {
|
||||
public:
|
||||
RpcServiceRequest(const std::string &product, const std::string &version,
|
||||
const std::string & action);
|
||||
virtual ~RpcServiceRequest();
|
||||
|
||||
std::string actionName()const;
|
||||
using ServiceRequest::setScheme;
|
||||
protected:
|
||||
void setActionName(const std::string &name);
|
||||
std::string actionName()const;
|
||||
using ServiceRequest::setScheme;
|
||||
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_
|
||||
protected:
|
||||
void setActionName(const std::string &name);
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_
|
||||
|
||||
@@ -14,22 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_RUNNABLE_H_
|
||||
#define ALIBABACLOUD_CORE_RUNNABLE_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_RUNNABLE_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_RUNNABLE_H_
|
||||
|
||||
#include <functional>
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT Runnable
|
||||
{
|
||||
public:
|
||||
explicit Runnable(const std::function<void()> f);
|
||||
void run()const;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT Runnable {
|
||||
public:
|
||||
explicit Runnable(const std::function<void()> f);
|
||||
void run()const;
|
||||
|
||||
private:
|
||||
std::function<void()> f_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_RUNNABLE_H_
|
||||
private:
|
||||
std::function<void()> f_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_RUNNABLE_H_
|
||||
|
||||
@@ -14,58 +14,61 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_SERVICEREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_SERVICEREQUEST_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICEREQUEST_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICEREQUEST_H_
|
||||
|
||||
#include <map>
|
||||
#include "CoreExport.h"
|
||||
#include "Url.h"
|
||||
#include <string>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT ServiceRequest
|
||||
{
|
||||
public:
|
||||
typedef std::string ParameterNameType;
|
||||
typedef std::string ParameterValueType;
|
||||
typedef std::map<ParameterNameType, ParameterValueType> ParameterCollection;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT ServiceRequest {
|
||||
public:
|
||||
typedef std::string ParameterNameType;
|
||||
typedef std::string ParameterValueType;
|
||||
typedef std::map<ParameterNameType, ParameterValueType> ParameterCollection;
|
||||
|
||||
virtual ~ServiceRequest();
|
||||
virtual ~ServiceRequest();
|
||||
|
||||
const char* content()const;
|
||||
size_t contentSize()const;
|
||||
bool hasContent()const;
|
||||
ParameterCollection parameters()const;
|
||||
std::string product()const;
|
||||
std::string resourcePath()const;
|
||||
std::string version()const;
|
||||
std::string scheme()const;
|
||||
protected:
|
||||
ServiceRequest(const std::string &product, const std::string &version);
|
||||
ServiceRequest(const ServiceRequest &other);
|
||||
ServiceRequest(ServiceRequest &&other);
|
||||
ServiceRequest& operator=(const ServiceRequest &other);
|
||||
ServiceRequest& operator=(ServiceRequest &&other);
|
||||
const char* content() const;
|
||||
size_t contentSize() const;
|
||||
bool hasContent() const;
|
||||
ParameterCollection parameters() const;
|
||||
std::string product() const;
|
||||
std::string resourcePath() const;
|
||||
std::string version() const;
|
||||
std::string scheme() const;
|
||||
|
||||
void addParameter(const ParameterNameType &name, const ParameterValueType &value);
|
||||
ParameterValueType parameter(const ParameterNameType &name)const;
|
||||
void removeParameter(const ParameterNameType &name);
|
||||
void setContent(const char *data, size_t size);
|
||||
void setParameter(const ParameterNameType &name, const ParameterValueType &value);
|
||||
void setParameters(const ParameterCollection ¶ms);
|
||||
void setResourcePath(const std::string &path);
|
||||
void setProduct(const std::string &product);
|
||||
void setVersion(const std::string &version);
|
||||
void setScheme(const std::string scheme);
|
||||
private:
|
||||
char *content_;
|
||||
size_t contentSize_;
|
||||
ParameterCollection params_;
|
||||
std::string product_;
|
||||
std::string resourcePath_;
|
||||
std::string version_;
|
||||
std::string scheme_;
|
||||
};
|
||||
}
|
||||
protected:
|
||||
ServiceRequest(const std::string &product, const std::string &version);
|
||||
ServiceRequest(const ServiceRequest &other);
|
||||
ServiceRequest(ServiceRequest &&other);
|
||||
ServiceRequest& operator=(const ServiceRequest &other);
|
||||
ServiceRequest& operator=(ServiceRequest &&other);
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_SERVICEREQUEST_H_
|
||||
void addParameter(const ParameterNameType &name,
|
||||
const ParameterValueType &value);
|
||||
ParameterValueType parameter(const ParameterNameType &name) const;
|
||||
void removeParameter(const ParameterNameType &name);
|
||||
void setContent(const char *data, size_t size);
|
||||
void setParameter(const ParameterNameType &name,
|
||||
const ParameterValueType &value);
|
||||
void setParameters(const ParameterCollection ¶ms);
|
||||
void setResourcePath(const std::string &path);
|
||||
void setProduct(const std::string &product);
|
||||
void setVersion(const std::string &version);
|
||||
void setScheme(const std::string scheme);
|
||||
|
||||
private:
|
||||
char *content_;
|
||||
size_t contentSize_;
|
||||
ParameterCollection params_;
|
||||
std::string product_;
|
||||
std::string resourcePath_;
|
||||
std::string version_;
|
||||
std::string scheme_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICEREQUEST_H_
|
||||
|
||||
@@ -14,27 +14,27 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_SERVICERESULT_H_
|
||||
#define ALIBABACLOUD_CORE_SERVICERESULT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICERESULT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICERESULT_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class PayloadReader;
|
||||
class ALIBABACLOUD_CORE_EXPORT ServiceResult
|
||||
{
|
||||
public:
|
||||
ServiceResult();
|
||||
virtual ~ServiceResult();
|
||||
namespace AlibabaCloud {
|
||||
class PayloadReader;
|
||||
class ALIBABACLOUD_CORE_EXPORT ServiceResult {
|
||||
public:
|
||||
ServiceResult();
|
||||
virtual ~ServiceResult();
|
||||
|
||||
std::string requestId()const;
|
||||
protected:
|
||||
void setRequestId(const std::string &requestId);
|
||||
private:
|
||||
std::string requestId()const;
|
||||
|
||||
protected:
|
||||
void setRequestId(const std::string &requestId);
|
||||
|
||||
private:
|
||||
std::string requestId_;
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_SERVICERESULT_H_
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SERVICERESULT_H_
|
||||
|
||||
@@ -14,33 +14,34 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_SIGNER_H_
|
||||
#define ALIBABACLOUD_CORE_SIGNER_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_SIGNER_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_SIGNER_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT Signer
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
HmacSha1,
|
||||
};
|
||||
virtual ~Signer();
|
||||
|
||||
virtual std::string generate(const std::string &src, const std::string &secret)const = 0;
|
||||
std::string name()const;
|
||||
Type type() const;
|
||||
std::string version()const;
|
||||
protected:
|
||||
Signer(Type type, const std::string &name, const std::string &version = "1.0");
|
||||
private:
|
||||
std::string name_;
|
||||
std::string version_;
|
||||
Type type_;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT Signer {
|
||||
public:
|
||||
enum Type {
|
||||
HmacSha1,
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_SIGNER_H_
|
||||
virtual ~Signer();
|
||||
|
||||
virtual std::string generate(const std::string &src,
|
||||
const std::string &secret)const = 0;
|
||||
std::string name()const;
|
||||
Type type() const;
|
||||
std::string version()const;
|
||||
|
||||
protected:
|
||||
Signer(Type type, const std::string &name,
|
||||
const std::string &version = "1.0");
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
std::string version_;
|
||||
Type type_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SIGNER_H_
|
||||
|
||||
@@ -14,24 +14,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_
|
||||
#define ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_
|
||||
|
||||
#include "CredentialsProvider.h"
|
||||
#include <string>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT SimpleCredentialsProvider : public CredentialsProvider
|
||||
{
|
||||
public:
|
||||
SimpleCredentialsProvider(const Credentials &credentials);
|
||||
SimpleCredentialsProvider(const std::string &accessKeyId,
|
||||
const std::string &accessKeySecret);
|
||||
~SimpleCredentialsProvider();
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT SimpleCredentialsProvider
|
||||
: public CredentialsProvider {
|
||||
public:
|
||||
explicit SimpleCredentialsProvider(const Credentials &credentials);
|
||||
SimpleCredentialsProvider(const std::string &accessKeyId,
|
||||
const std::string &accessKeySecret);
|
||||
~SimpleCredentialsProvider();
|
||||
|
||||
virtual Credentials getCredentials() override;
|
||||
private:
|
||||
Credentials credentials_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_
|
||||
Credentials getCredentials() override;
|
||||
|
||||
private:
|
||||
Credentials credentials_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_
|
||||
|
||||
@@ -14,41 +14,42 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_STS_STSASSUMEROLECREDENTIALSPROVIDER_H_
|
||||
#define ALIBABACLOUD_STS_STSASSUMEROLECREDENTIALSPROVIDER_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_STSASSUMEROLECREDENTIALSPROVIDER_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_STSASSUMEROLECREDENTIALSPROVIDER_H_
|
||||
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <alibabacloud/core/CredentialsProvider.h>
|
||||
#include <alibabacloud/core/sts/StsClient.h>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
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);
|
||||
~StsAssumeRoleCredentialsProvider();
|
||||
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);
|
||||
~StsAssumeRoleCredentialsProvider();
|
||||
|
||||
virtual Credentials getCredentials() override;
|
||||
using StsClient::assumeRole;
|
||||
private:
|
||||
void loadCredentials();
|
||||
bool checkExpiry()const;
|
||||
Credentials getCredentials() override;
|
||||
using StsClient::assumeRole;
|
||||
|
||||
std::mutex cachedMutex_;
|
||||
Credentials cachedCredentials_;
|
||||
int durationSeconds_;
|
||||
std::chrono::system_clock::time_point expiry_;
|
||||
std::string policy_;
|
||||
std::string roleArn_;
|
||||
std::string roleSessionName_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_STSASSUMEROLECREDENTIALSPROVIDER_H_
|
||||
private:
|
||||
void loadCredentials();
|
||||
bool checkExpiry()const;
|
||||
|
||||
std::mutex cachedMutex_;
|
||||
Credentials cachedCredentials_;
|
||||
int durationSeconds_;
|
||||
std::chrono::system_clock::time_point expiry_;
|
||||
std::string policy_;
|
||||
std::string roleArn_;
|
||||
std::string roleSessionName_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_STSASSUMEROLECREDENTIALSPROVIDER_H_
|
||||
|
||||
@@ -14,62 +14,61 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_URL_H_
|
||||
#define ALIBABACLOUD_CORE_URL_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_URL_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_URL_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
#include <string>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT Url
|
||||
{
|
||||
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;
|
||||
bool operator==(const Url &url) const;
|
||||
bool operator!=(const Url &url) const;
|
||||
namespace AlibabaCloud {
|
||||
class ALIBABACLOUD_CORE_EXPORT Url {
|
||||
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;
|
||||
bool operator==(const Url &url) const;
|
||||
bool operator!=(const Url &url) const;
|
||||
|
||||
std::string authority() const;
|
||||
void clear();
|
||||
std::string fragment() const;
|
||||
void fromString(const std::string &url);
|
||||
bool hasFragment() const;
|
||||
bool hasQuery() const;
|
||||
std::string host()const;
|
||||
bool isEmpty() const;
|
||||
bool isValid() const;
|
||||
int port()const;
|
||||
std::string password() const;
|
||||
std::string path() const;
|
||||
std::string query() const;
|
||||
std::string scheme() const;
|
||||
void setAuthority(const std::string &authority);
|
||||
void setFragment(const std::string &fragment);
|
||||
void setHost(const std::string &host);
|
||||
void setPassword(const std::string &password);
|
||||
void setPath(const std::string &path);
|
||||
void setPort(int port);
|
||||
void setQuery(const std::string &query);
|
||||
void setScheme(const std::string &scheme);
|
||||
void setUserInfo(const std::string &userInfo);
|
||||
void setUserName(const std::string &userName);
|
||||
std::string toString()const;
|
||||
std::string userInfo() const;
|
||||
std::string userName() const;
|
||||
private:
|
||||
std::string scheme_;
|
||||
std::string userName_;
|
||||
std::string password_;
|
||||
std::string host_;
|
||||
std::string path_;
|
||||
int port_;
|
||||
std::string query_;
|
||||
std::string fragment_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_URL_H_
|
||||
std::string authority() const;
|
||||
void clear();
|
||||
std::string fragment() const;
|
||||
void fromString(const std::string &url);
|
||||
bool hasFragment() const;
|
||||
bool hasQuery() const;
|
||||
std::string host()const;
|
||||
bool isEmpty() const;
|
||||
bool isValid() const;
|
||||
int port()const;
|
||||
std::string password() const;
|
||||
std::string path() const;
|
||||
std::string query() const;
|
||||
std::string scheme() const;
|
||||
void setAuthority(const std::string &authority);
|
||||
void setFragment(const std::string &fragment);
|
||||
void setHost(const std::string &host);
|
||||
void setPassword(const std::string &password);
|
||||
void setPath(const std::string &path);
|
||||
void setPort(int port);
|
||||
void setQuery(const std::string &query);
|
||||
void setScheme(const std::string &scheme);
|
||||
void setUserInfo(const std::string &userInfo);
|
||||
void setUserName(const std::string &userName);
|
||||
std::string toString() const;
|
||||
std::string userInfo() const;
|
||||
std::string userName() const;
|
||||
|
||||
private:
|
||||
std::string scheme_;
|
||||
std::string userName_;
|
||||
std::string password_;
|
||||
std::string host_;
|
||||
std::string path_;
|
||||
int port_;
|
||||
std::string query_;
|
||||
std::string fragment_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_URL_H_
|
||||
|
||||
@@ -14,38 +14,53 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_
|
||||
|
||||
#include <future>
|
||||
#include <alibabacloud/core/AsyncCallerContext.h>
|
||||
#include <alibabacloud/core/RpcServiceClient.h>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "model/DescribeEndpointsRequest.h"
|
||||
#include "model/DescribeEndpointsResult.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Location
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT LocationClient : public RpcServiceClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, Model::DescribeEndpointsResult> DescribeEndpointsOutcome;
|
||||
typedef std::future<DescribeEndpointsOutcome> DescribeEndpointsOutcomeCallable;
|
||||
typedef std::function<void(const LocationClient*, const Model::DescribeEndpointsRequest&, const DescribeEndpointsOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DescribeEndpointsAsyncHandler;
|
||||
|
||||
LocationClient(const Credentials &credentials, const ClientConfiguration &configuration);
|
||||
LocationClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||
LocationClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
|
||||
LocationClient(const std::shared_ptr<Location::LocationClient>& locationClient);
|
||||
~LocationClient();
|
||||
virtual DescribeEndpointsOutcome describeEndpoints(const Model::DescribeEndpointsRequest &request)const;
|
||||
void describeEndpointsAsync(const Model::DescribeEndpointsRequest& request, const DescribeEndpointsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
DescribeEndpointsOutcomeCallable describeEndpointsCallable(const Model::DescribeEndpointsRequest& request) const;
|
||||
using RpcServiceClient::makeRequest;
|
||||
using RpcServiceClient::configuration;
|
||||
};
|
||||
}
|
||||
}
|
||||
namespace AlibabaCloud {
|
||||
namespace Location {
|
||||
class ALIBABACLOUD_CORE_EXPORT LocationClient : public RpcServiceClient {
|
||||
public:
|
||||
typedef Outcome<Error, Model::DescribeEndpointsResult>
|
||||
DescribeEndpointsOutcome;
|
||||
typedef std::future<DescribeEndpointsOutcome>
|
||||
DescribeEndpointsOutcomeCallable;
|
||||
typedef std::function<void(const LocationClient*,
|
||||
const Model::DescribeEndpointsRequest&, const DescribeEndpointsOutcome&,
|
||||
const std::shared_ptr<const AsyncCallerContext>&)>
|
||||
DescribeEndpointsAsyncHandler;
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_
|
||||
LocationClient(const Credentials &credentials,
|
||||
const ClientConfiguration &configuration);
|
||||
LocationClient(
|
||||
const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration);
|
||||
LocationClient(const std::string &accessKeyId,
|
||||
const std::string &accessKeySecret,
|
||||
const ClientConfiguration &configuration);
|
||||
LocationClient(
|
||||
const std::shared_ptr<Location::LocationClient>& locationClient);
|
||||
~LocationClient();
|
||||
virtual DescribeEndpointsOutcome describeEndpoints(
|
||||
const Model::DescribeEndpointsRequest &request)const;
|
||||
void describeEndpointsAsync(const Model::DescribeEndpointsRequest& request,
|
||||
const DescribeEndpointsAsyncHandler& handler,
|
||||
const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
DescribeEndpointsOutcomeCallable describeEndpointsCallable(
|
||||
const Model::DescribeEndpointsRequest& request) const;
|
||||
using RpcServiceClient::makeRequest;
|
||||
using RpcServiceClient::configuration;
|
||||
};
|
||||
} // namespace Location
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_
|
||||
|
||||
@@ -14,25 +14,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_
|
||||
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
#include <string>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Location
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT LocationRequest : public RpcServiceRequest
|
||||
{
|
||||
public:
|
||||
explicit LocationRequest(const std::string & action);
|
||||
virtual ~LocationRequest();
|
||||
namespace AlibabaCloud {
|
||||
namespace Location {
|
||||
class ALIBABACLOUD_CORE_EXPORT LocationRequest : public RpcServiceRequest {
|
||||
public:
|
||||
explicit LocationRequest(const std::string & action);
|
||||
virtual ~LocationRequest();
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
} // namespace Location
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_
|
||||
|
||||
@@ -14,33 +14,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSREQUEST_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSREQUEST_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <alibabacloud/core/location/LocationRequest.h>
|
||||
#include <string>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Location
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT DescribeEndpointsRequest : public LocationRequest
|
||||
{
|
||||
public:
|
||||
DescribeEndpointsRequest();
|
||||
~DescribeEndpointsRequest();
|
||||
namespace AlibabaCloud {
|
||||
namespace Location {
|
||||
namespace Model {
|
||||
class ALIBABACLOUD_CORE_EXPORT DescribeEndpointsRequest
|
||||
: public LocationRequest {
|
||||
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);
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSREQUEST_H_
|
||||
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_
|
||||
|
||||
@@ -14,51 +14,46 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_
|
||||
#define ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_
|
||||
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Location
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT DescribeEndpointsResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
struct Endpoint
|
||||
{
|
||||
std::string endpoint;
|
||||
std::string id;
|
||||
std::string namespace_;
|
||||
std::string serivceCode;
|
||||
std::string type;
|
||||
std::vector<std::string> protocols;
|
||||
};
|
||||
namespace AlibabaCloud {
|
||||
namespace Location {
|
||||
namespace Model {
|
||||
class ALIBABACLOUD_CORE_EXPORT DescribeEndpointsResult : public ServiceResult {
|
||||
public:
|
||||
struct Endpoint {
|
||||
std::string endpoint;
|
||||
std::string id;
|
||||
std::string namespace_;
|
||||
std::string serivceCode;
|
||||
std::string type;
|
||||
std::vector<std::string> protocols;
|
||||
};
|
||||
|
||||
DescribeEndpointsResult();
|
||||
explicit DescribeEndpointsResult(const std::string &payload);
|
||||
~DescribeEndpointsResult();
|
||||
DescribeEndpointsResult();
|
||||
explicit DescribeEndpointsResult(const std::string &payload);
|
||||
~DescribeEndpointsResult();
|
||||
|
||||
std::vector<Endpoint> endpoints()const;
|
||||
void setEndpoints(const std::vector<Endpoint> &endpoints);
|
||||
std::vector<Endpoint> endpoints()const;
|
||||
void setEndpoints(const std::vector<Endpoint> &endpoints);
|
||||
|
||||
bool success()const;
|
||||
void setSuccess(const bool &success);
|
||||
bool success()const;
|
||||
void setSuccess(const bool &success);
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
std::vector<Endpoint> endpoints_;
|
||||
bool success_;
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_
|
||||
private:
|
||||
std::vector<Endpoint> endpoints_;
|
||||
bool success_;
|
||||
};
|
||||
} // namespace Model
|
||||
} // namespace Location
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_
|
||||
|
||||
@@ -14,46 +14,64 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_STS_STSCLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_STS_STSCLIENT_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSCLIENT_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSCLIENT_H_
|
||||
|
||||
#include <future>
|
||||
#include <alibabacloud/core/AsyncCallerContext.h>
|
||||
#include <alibabacloud/core/RpcServiceClient.h>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#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:
|
||||
typedef Outcome<Error, Model::AssumeRoleResult> AssumeRoleOutcome;
|
||||
typedef std::future<AssumeRoleOutcome> AssumeRoleOutcomeCallable;
|
||||
typedef std::function<void(const StsClient*, const Model::AssumeRoleRequest&, const AssumeRoleOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> AssumeRoleAsyncHandler;
|
||||
|
||||
typedef Outcome<Error, Model::GetCallerIdentityResult> GetCallerIdentityOutcome;
|
||||
typedef std::future<GetCallerIdentityOutcome> GetCallerIdentityOutcomeCallable;
|
||||
typedef std::function<void(const StsClient*, const Model::GetCallerIdentityRequest&, const GetCallerIdentityOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetCallerIdentityAsyncHandler;
|
||||
namespace AlibabaCloud {
|
||||
namespace Sts {
|
||||
class ALIBABACLOUD_CORE_EXPORT StsClient : public RpcServiceClient {
|
||||
public:
|
||||
typedef Outcome<Error, Model::AssumeRoleResult> AssumeRoleOutcome;
|
||||
typedef std::future<AssumeRoleOutcome> AssumeRoleOutcomeCallable;
|
||||
typedef std::function<void(const StsClient*,
|
||||
const Model::AssumeRoleRequest&, const AssumeRoleOutcome&,
|
||||
const std::shared_ptr<const AsyncCallerContext>&)> AssumeRoleAsyncHandler;
|
||||
|
||||
StsClient(const Credentials &credentials, const ClientConfiguration &configuration);
|
||||
StsClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||
StsClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
|
||||
~StsClient();
|
||||
typedef Outcome<Error, Model::GetCallerIdentityResult>
|
||||
GetCallerIdentityOutcome;
|
||||
typedef std::future<GetCallerIdentityOutcome>
|
||||
GetCallerIdentityOutcomeCallable;
|
||||
typedef std::function<void(const StsClient*,
|
||||
const Model::GetCallerIdentityRequest&, const GetCallerIdentityOutcome&,
|
||||
const std::shared_ptr<const AsyncCallerContext>&)>
|
||||
GetCallerIdentityAsyncHandler;
|
||||
|
||||
virtual AssumeRoleOutcome assumeRole(const Model::AssumeRoleRequest &request)const;
|
||||
void assumeRoleAsync(const Model::AssumeRoleRequest& request, const AssumeRoleAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
AssumeRoleOutcomeCallable assumeRoleCallable(const Model::AssumeRoleRequest& request) const;
|
||||
GetCallerIdentityOutcome getCallerIdentity(const Model::GetCallerIdentityRequest &request)const;
|
||||
void getCallerIdentityAsync(const Model::GetCallerIdentityRequest& request, const GetCallerIdentityAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
GetCallerIdentityOutcomeCallable getCallerIdentityCallable(const Model::GetCallerIdentityRequest& request) const;
|
||||
using RpcServiceClient::makeRequest;
|
||||
};
|
||||
}
|
||||
}
|
||||
StsClient(const Credentials &credentials,
|
||||
const ClientConfiguration &configuration);
|
||||
StsClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration);
|
||||
StsClient(const std::string &accessKeyId, const std::string &accessKeySecret,
|
||||
const ClientConfiguration &configuration);
|
||||
~StsClient();
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_STS_STSCLIENT_H_
|
||||
virtual AssumeRoleOutcome assumeRole(
|
||||
const Model::AssumeRoleRequest &request) const;
|
||||
void assumeRoleAsync(const Model::AssumeRoleRequest& request,
|
||||
const AssumeRoleAsyncHandler& handler,
|
||||
const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
AssumeRoleOutcomeCallable assumeRoleCallable(
|
||||
const Model::AssumeRoleRequest& request) const;
|
||||
GetCallerIdentityOutcome getCallerIdentity(
|
||||
const Model::GetCallerIdentityRequest &request)const;
|
||||
void getCallerIdentityAsync(const Model::GetCallerIdentityRequest& request,
|
||||
const GetCallerIdentityAsyncHandler& handler,
|
||||
const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
GetCallerIdentityOutcomeCallable getCallerIdentityCallable(
|
||||
const Model::GetCallerIdentityRequest& request) const;
|
||||
using RpcServiceClient::makeRequest;
|
||||
};
|
||||
} // namespace Sts
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSCLIENT_H_
|
||||
|
||||
@@ -14,25 +14,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_STS_STSSERVICEREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_STS_STSSERVICEREQUEST_H_
|
||||
#ifndef CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSREQUEST_H_
|
||||
#define CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSREQUEST_H_
|
||||
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
#include <string>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT StsRequest : public RpcServiceRequest
|
||||
{
|
||||
public:
|
||||
explicit StsRequest(const std::string & action);
|
||||
virtual ~StsRequest();
|
||||
namespace AlibabaCloud {
|
||||
namespace Sts {
|
||||
class ALIBABACLOUD_CORE_EXPORT StsRequest : public RpcServiceRequest {
|
||||
public:
|
||||
explicit StsRequest(const std::string & action);
|
||||
virtual ~StsRequest();
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
} // namespace Sts
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_STS_STSSERVICEREQUEST_H_
|
||||
#endif // CORE_INCLUDE_ALIBABACLOUD_CORE_STS_STSREQUEST_H_
|
||||
|
||||
@@ -20,14 +20,10 @@
|
||||
#include <string>
|
||||
#include <alibabacloud/core/sts/StsRequest.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT AssumeRoleRequest : public StsRequest
|
||||
{
|
||||
namespace AlibabaCloud {
|
||||
namespace Sts {
|
||||
namespace Model {
|
||||
class ALIBABACLOUD_CORE_EXPORT AssumeRoleRequest : public StsRequest {
|
||||
public:
|
||||
AssumeRoleRequest();
|
||||
~AssumeRoleRequest();
|
||||
|
||||
@@ -19,22 +19,16 @@
|
||||
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT AssumeRoleResult : public ServiceResult
|
||||
{
|
||||
namespace AlibabaCloud {
|
||||
namespace Sts {
|
||||
namespace Model {
|
||||
class ALIBABACLOUD_CORE_EXPORT AssumeRoleResult : public ServiceResult {
|
||||
public:
|
||||
struct AssumedRoleUser
|
||||
{
|
||||
struct AssumedRoleUser {
|
||||
std::string arn;
|
||||
std::string assumedRoleId;
|
||||
};
|
||||
struct Credentials
|
||||
{
|
||||
struct Credentials {
|
||||
std::string accessKeyId;
|
||||
std::string accessKeySecret;
|
||||
std::string expiration;
|
||||
|
||||
@@ -20,14 +20,10 @@
|
||||
#include <string>
|
||||
#include <alibabacloud/core/sts/StsRequest.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityRequest : public StsRequest
|
||||
{
|
||||
namespace AlibabaCloud {
|
||||
namespace Sts {
|
||||
namespace Model {
|
||||
class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityRequest : public StsRequest {
|
||||
public:
|
||||
GetCallerIdentityRequest();
|
||||
~GetCallerIdentityRequest();
|
||||
|
||||
@@ -19,14 +19,10 @@
|
||||
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityResult : public ServiceResult
|
||||
{
|
||||
namespace AlibabaCloud {
|
||||
namespace Sts {
|
||||
namespace Model {
|
||||
class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityResult : public ServiceResult {
|
||||
public:
|
||||
GetCallerIdentityResult();
|
||||
explicit GetCallerIdentityResult(const std::string &payload);
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
static AlibabaCloud::Executor * executor = nullptr;
|
||||
|
||||
void AlibabaCloud::InitializeSdk()
|
||||
{
|
||||
void AlibabaCloud::InitializeSdk() {
|
||||
if (IsSdkInitialized())
|
||||
return;
|
||||
|
||||
@@ -28,13 +27,11 @@ void AlibabaCloud::InitializeSdk()
|
||||
executor->start();
|
||||
}
|
||||
|
||||
bool AlibabaCloud::IsSdkInitialized()
|
||||
{
|
||||
bool AlibabaCloud::IsSdkInitialized() {
|
||||
return executor != nullptr;
|
||||
}
|
||||
|
||||
void AlibabaCloud::ShutdownSdk()
|
||||
{
|
||||
void AlibabaCloud::ShutdownSdk() {
|
||||
if (!IsSdkInitialized())
|
||||
return;
|
||||
|
||||
|
||||
@@ -17,28 +17,25 @@
|
||||
#include <alibabacloud/core/AsyncCallerContext.h>
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
AsyncCallerContext::AsyncCallerContext() :
|
||||
uuid_(GenerateUuid())
|
||||
{
|
||||
uuid_(GenerateUuid()) {
|
||||
}
|
||||
|
||||
AsyncCallerContext::AsyncCallerContext(const std::string &uuid) :
|
||||
uuid_(uuid)
|
||||
{
|
||||
uuid_(uuid) {
|
||||
}
|
||||
|
||||
AsyncCallerContext::~AsyncCallerContext()
|
||||
{
|
||||
AsyncCallerContext::~AsyncCallerContext() {
|
||||
}
|
||||
|
||||
std::string AsyncCallerContext::uuid()const
|
||||
{
|
||||
std::string AsyncCallerContext::uuid()const {
|
||||
return uuid_;
|
||||
}
|
||||
|
||||
void AsyncCallerContext::setUuid(const std::string &uuid)
|
||||
{
|
||||
void AsyncCallerContext::setUuid(const std::string &uuid) {
|
||||
uuid_ = uuid;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,46 +16,40 @@
|
||||
|
||||
#include <alibabacloud/core/ClientConfiguration.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
ClientConfiguration::ClientConfiguration(const std::string ®ionId,
|
||||
const NetworkProxy &proxy):
|
||||
regionId_(regionId),
|
||||
proxy_(proxy),
|
||||
endpoint_()
|
||||
{
|
||||
endpoint_() {
|
||||
}
|
||||
|
||||
ClientConfiguration::~ClientConfiguration()
|
||||
{
|
||||
ClientConfiguration::~ClientConfiguration() {
|
||||
}
|
||||
|
||||
std::string ClientConfiguration::endpoint() const
|
||||
{
|
||||
std::string ClientConfiguration::endpoint() const {
|
||||
return endpoint_;
|
||||
}
|
||||
|
||||
NetworkProxy ClientConfiguration::proxy()const
|
||||
{
|
||||
NetworkProxy ClientConfiguration::proxy()const {
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
std::string ClientConfiguration::regionId()const
|
||||
{
|
||||
std::string ClientConfiguration::regionId()const {
|
||||
return regionId_;
|
||||
}
|
||||
|
||||
void ClientConfiguration::setEndpoint(const std::string & endpoint)
|
||||
{
|
||||
void ClientConfiguration::setEndpoint(const std::string & endpoint) {
|
||||
endpoint_ = endpoint;
|
||||
}
|
||||
|
||||
void ClientConfiguration::setProxy(const NetworkProxy &proxy)
|
||||
{
|
||||
void ClientConfiguration::setProxy(const NetworkProxy &proxy) {
|
||||
proxy_ = proxy;
|
||||
}
|
||||
|
||||
void ClientConfiguration::setRegionId(const std::string ®ionId)
|
||||
{
|
||||
void ClientConfiguration::setRegionId(const std::string ®ionId) {
|
||||
regionId_ = regionId;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -15,49 +15,51 @@
|
||||
*/
|
||||
|
||||
#include <alibabacloud/core/CommonClient.h>
|
||||
#include <alibabacloud/core/location/LocationClient.h>
|
||||
#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <alibabacloud/core/location/LocationClient.h>
|
||||
#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
using namespace Location;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
const std::string SERVICE_NAME = "Common";
|
||||
}
|
||||
|
||||
CommonClient::CommonClient(const Credentials &credentials, const ClientConfiguration &configuration) :
|
||||
CommonClient::CommonClient(const Credentials &credentials,
|
||||
const ClientConfiguration &configuration) :
|
||||
CoreClient(SERVICE_NAME, configuration),
|
||||
credentialsProvider_(std::make_shared<SimpleCredentialsProvider>(credentials)),
|
||||
signer_(std::make_shared<HmacSha1Signer>())
|
||||
{
|
||||
credentialsProvider_(
|
||||
std::make_shared<SimpleCredentialsProvider>(credentials)),
|
||||
signer_(std::make_shared<HmacSha1Signer>()) {
|
||||
}
|
||||
|
||||
CommonClient::CommonClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
|
||||
CommonClient::CommonClient(
|
||||
const std::shared_ptr<CredentialsProvider>& credentialsProvider,
|
||||
const ClientConfiguration & configuration) :
|
||||
CoreClient(SERVICE_NAME, configuration),
|
||||
credentialsProvider_(credentialsProvider),
|
||||
signer_(std::make_shared<HmacSha1Signer>())
|
||||
{
|
||||
signer_(std::make_shared<HmacSha1Signer>()) {
|
||||
}
|
||||
|
||||
CommonClient::CommonClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
|
||||
CommonClient::CommonClient(const std::string & accessKeyId,
|
||||
const std::string & accessKeySecret,
|
||||
const ClientConfiguration & configuration) :
|
||||
CoreClient(SERVICE_NAME, configuration),
|
||||
credentialsProvider_(std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret)),
|
||||
signer_(std::make_shared<HmacSha1Signer>())
|
||||
{
|
||||
credentialsProvider_(std::make_shared<SimpleCredentialsProvider>(accessKeyId,
|
||||
accessKeySecret)),
|
||||
signer_(std::make_shared<HmacSha1Signer>()) {
|
||||
}
|
||||
|
||||
CommonClient::~CommonClient()
|
||||
{
|
||||
CommonClient::~CommonClient() {
|
||||
}
|
||||
|
||||
CommonClient::JsonOutcome CommonClient::makeRequest(const std::string &endpoint, const CommonRequest &msg, HttpRequest::Method method)const
|
||||
{
|
||||
CommonClient::JsonOutcome CommonClient::makeRequest(const std::string &endpoint,
|
||||
const CommonRequest &msg, HttpRequest::Method method)const {
|
||||
auto outcome = AttemptRequest(endpoint, msg, method);
|
||||
if (outcome.isSuccess())
|
||||
return JsonOutcome(std::string(outcome.result().body(),
|
||||
@@ -66,8 +68,8 @@ CommonClient::JsonOutcome CommonClient::makeRequest(const std::string &endpoint,
|
||||
return JsonOutcome(outcome.error());
|
||||
}
|
||||
|
||||
CommonClient::CommonResponseOutcome CommonClient::commonResponse(const CommonRequest & request) const
|
||||
{
|
||||
CommonClient::CommonResponseOutcome CommonClient::commonResponse(
|
||||
const CommonRequest & request) const {
|
||||
auto outcome = makeRequest(request.domain(), request, request.httpMethod());
|
||||
if (outcome.isSuccess())
|
||||
return CommonResponseOutcome(CommonResponse(outcome.result()));
|
||||
@@ -75,21 +77,20 @@ CommonClient::CommonResponseOutcome CommonClient::commonResponse(const CommonReq
|
||||
return CommonResponseOutcome(Error(outcome.error()));
|
||||
}
|
||||
|
||||
void CommonClient::commonResponseAsync(const CommonRequest & request, const CommonResponseAsyncHandler & handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
void CommonClient::commonResponseAsync(const CommonRequest & request,
|
||||
const CommonResponseAsyncHandler & handler,
|
||||
const std::shared_ptr<const AsyncCallerContext>& context) const {
|
||||
auto fn = [this, request, handler, context]() {
|
||||
handler(this, request, commonResponse(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
CommonClient::CommonResponseOutcomeCallable CommonClient::commonResponseCallable(const CommonRequest & request) const
|
||||
{
|
||||
CommonClient::CommonResponseOutcomeCallable
|
||||
CommonClient::commonResponseCallable(const CommonRequest & request) const {
|
||||
auto task = std::make_shared<std::packaged_task<CommonResponseOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
[this, request]() {
|
||||
return this->commonResponse(request);
|
||||
});
|
||||
|
||||
@@ -97,21 +98,22 @@ CommonClient::CommonResponseOutcomeCallable CommonClient::commonResponseCallable
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
HttpRequest CommonClient::buildHttpRequest(const std::string & endpoint, const ServiceRequest & msg, HttpRequest::Method method) const
|
||||
{
|
||||
return buildHttpRequest(endpoint, dynamic_cast<const CommonRequest& >(msg), method);
|
||||
HttpRequest CommonClient::buildHttpRequest(const std::string & endpoint,
|
||||
const ServiceRequest & msg, HttpRequest::Method method) const {
|
||||
return buildHttpRequest(endpoint,
|
||||
dynamic_cast<const CommonRequest& >(msg), method);
|
||||
}
|
||||
|
||||
HttpRequest CommonClient::buildHttpRequest(const std::string & endpoint, const CommonRequest &msg, HttpRequest::Method method) const
|
||||
{
|
||||
HttpRequest CommonClient::buildHttpRequest(const std::string & endpoint,
|
||||
const CommonRequest &msg, HttpRequest::Method method) const {
|
||||
if (msg.requestPattern() == CommonRequest::RpcPattern)
|
||||
return buildRpcHttpRequest(endpoint, msg, method);
|
||||
else
|
||||
return buildRoaHttpRequest(endpoint, msg, method);
|
||||
}
|
||||
|
||||
HttpRequest CommonClient::buildRoaHttpRequest(const std::string & endpoint, const CommonRequest &msg, HttpRequest::Method method) const
|
||||
{
|
||||
HttpRequest CommonClient::buildRoaHttpRequest(const std::string & endpoint,
|
||||
const CommonRequest &msg, HttpRequest::Method method) const {
|
||||
const Credentials credentials = credentialsProvider_->getCredentials();
|
||||
|
||||
Url url;
|
||||
@@ -132,8 +134,7 @@ HttpRequest CommonClient::buildRoaHttpRequest(const std::string & endpoint, cons
|
||||
|
||||
if (!queryParams.empty()) {
|
||||
std::stringstream queryString;
|
||||
for (const auto &p : queryParams)
|
||||
{
|
||||
for (const auto &p : queryParams) {
|
||||
if (p.second.empty())
|
||||
queryString << "&" << p.first;
|
||||
else
|
||||
@@ -153,12 +154,13 @@ HttpRequest CommonClient::buildRoaHttpRequest(const std::string & endpoint, cons
|
||||
std::stringstream ss;
|
||||
ss << msg.contentSize();
|
||||
request.setHeader("Content-Length", ss.str());
|
||||
if(msg.headerParameter("Content-Type").empty()) {
|
||||
if (msg.headerParameter("Content-Type").empty()) {
|
||||
request.setHeader("Content-Type", "application/octet-stream");
|
||||
} else {
|
||||
request.setHeader("Content-Type", msg.headerParameter("Content-Type"));
|
||||
}
|
||||
request.setHeader("Content-MD5", ComputeContentMD5(msg.content(), msg.contentSize()));
|
||||
request.setHeader("Content-MD5",
|
||||
ComputeContentMD5(msg.content(), msg.contentSize()));
|
||||
request.setBody(msg.content(), msg.contentSize());
|
||||
|
||||
std::time_t t = std::time(nullptr);
|
||||
@@ -172,7 +174,8 @@ HttpRequest CommonClient::buildRoaHttpRequest(const std::string & endpoint, cons
|
||||
#endif
|
||||
request.setHeader("Date", date.str());
|
||||
request.setHeader("Host", url.host());
|
||||
request.setHeader("x-sdk-client", std::string("CPP/").append(ALIBABACLOUD_VERSION_STR));
|
||||
request.setHeader("x-sdk-client",
|
||||
std::string("CPP/").append(ALIBABACLOUD_VERSION_STR));
|
||||
request.setHeader("x-acs-region-id", configuration().regionId());
|
||||
if (!credentials.sessionToken().empty())
|
||||
request.setHeader("x-acs-security-token", credentials.sessionToken());
|
||||
@@ -202,8 +205,8 @@ HttpRequest CommonClient::buildRoaHttpRequest(const std::string & endpoint, cons
|
||||
return request;
|
||||
}
|
||||
|
||||
HttpRequest CommonClient::buildRpcHttpRequest(const std::string & endpoint, const CommonRequest &msg, HttpRequest::Method method) const
|
||||
{
|
||||
HttpRequest CommonClient::buildRpcHttpRequest(const std::string & endpoint,
|
||||
const CommonRequest &msg, HttpRequest::Method method) const {
|
||||
const Credentials credentials = credentialsProvider_->getCredentials();
|
||||
|
||||
Url url;
|
||||
@@ -248,7 +251,8 @@ HttpRequest CommonClient::buildRpcHttpRequest(const std::string & endpoint, cons
|
||||
<< "&"
|
||||
<< UrlEncode(canonicalizedQuery(queryParams));
|
||||
|
||||
queryParams["Signature"] = signer_->generate(plaintext.str(), credentials.accessKeySecret() + "&");
|
||||
queryParams["Signature"] = signer_->generate(plaintext.str(),
|
||||
credentials.accessKeySecret() + "&");
|
||||
|
||||
std::stringstream queryString;
|
||||
for (const auto &p : queryParams)
|
||||
@@ -258,6 +262,9 @@ HttpRequest CommonClient::buildRpcHttpRequest(const std::string & endpoint, cons
|
||||
HttpRequest request(url);
|
||||
request.setMethod(method);
|
||||
request.setHeader("Host", url.host());
|
||||
request.setHeader("x-sdk-client", std::string("CPP/").append(ALIBABACLOUD_VERSION_STR));
|
||||
request.setHeader("x-sdk-client",
|
||||
std::string("CPP/").append(ALIBABACLOUD_VERSION_STR));
|
||||
return request;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,54 +16,45 @@
|
||||
|
||||
#include <alibabacloud/core/CommonRequest.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
CommonRequest::CommonRequest(RequestPattern pattern):
|
||||
ServiceRequest("",""),
|
||||
ServiceRequest("", ""),
|
||||
domain_(),
|
||||
queryParams_(),
|
||||
httpMethod_(HttpRequest::Get),
|
||||
requestPattern_(pattern)
|
||||
{
|
||||
requestPattern_(pattern) {
|
||||
}
|
||||
|
||||
CommonRequest::~CommonRequest()
|
||||
{
|
||||
|
||||
CommonRequest::~CommonRequest() {
|
||||
}
|
||||
|
||||
std::string CommonRequest::domain()const
|
||||
{
|
||||
std::string CommonRequest::domain()const {
|
||||
return domain_;
|
||||
}
|
||||
|
||||
void CommonRequest::setDomain(const std::string &domain)
|
||||
{
|
||||
void CommonRequest::setDomain(const std::string &domain) {
|
||||
domain_ = domain;
|
||||
}
|
||||
|
||||
CommonRequest::RequestPattern CommonRequest::requestPattern() const
|
||||
{
|
||||
CommonRequest::RequestPattern CommonRequest::requestPattern() const {
|
||||
return requestPattern_;
|
||||
}
|
||||
|
||||
void CommonRequest::setRequestPattern(RequestPattern pattern)
|
||||
{
|
||||
void CommonRequest::setRequestPattern(RequestPattern pattern) {
|
||||
requestPattern_ = pattern;
|
||||
}
|
||||
|
||||
void CommonRequest::setHttpMethod(HttpRequest::Method method)
|
||||
{
|
||||
void CommonRequest::setHttpMethod(HttpRequest::Method method) {
|
||||
httpMethod_ = method;
|
||||
}
|
||||
|
||||
HttpRequest::Method CommonRequest::httpMethod() const
|
||||
{
|
||||
HttpRequest::Method CommonRequest::httpMethod() const {
|
||||
return httpMethod_;
|
||||
}
|
||||
|
||||
CommonRequest::ParameterValueType CommonRequest::queryParameter(const ParameterNameType &name)const
|
||||
{
|
||||
CommonRequest::ParameterValueType CommonRequest::queryParameter(
|
||||
const ParameterNameType &name) const {
|
||||
ParameterCollection::const_iterator it = queryParams_.find(name);
|
||||
if (it == queryParams_.end()) {
|
||||
return ParameterValueType("");
|
||||
@@ -72,18 +63,17 @@ CommonRequest::ParameterValueType CommonRequest::queryParameter(const ParameterN
|
||||
}
|
||||
|
||||
|
||||
CommonRequest::ParameterCollection CommonRequest::queryParameters() const
|
||||
{
|
||||
CommonRequest::ParameterCollection CommonRequest::queryParameters() const {
|
||||
return queryParams_;
|
||||
}
|
||||
|
||||
void CommonRequest::setQueryParameter(const ParameterNameType &name, const ParameterValueType &value)
|
||||
{
|
||||
void CommonRequest::setQueryParameter(const ParameterNameType &name,
|
||||
const ParameterValueType &value) {
|
||||
queryParams_[name] = value;
|
||||
}
|
||||
|
||||
CommonRequest::ParameterValueType CommonRequest::headerParameter(const ParameterNameType &name)const
|
||||
{
|
||||
CommonRequest::ParameterValueType CommonRequest::headerParameter(
|
||||
const ParameterNameType &name) const {
|
||||
const ParameterCollection::const_iterator it = headerParams_.find(name);
|
||||
if (it == headerParams_.end()) {
|
||||
return ParameterValueType("");
|
||||
@@ -91,12 +81,13 @@ CommonRequest::ParameterValueType CommonRequest::headerParameter(const Parameter
|
||||
return it->second;
|
||||
}
|
||||
|
||||
CommonRequest::ParameterCollection CommonRequest::headerParameters() const
|
||||
{
|
||||
CommonRequest::ParameterCollection CommonRequest::headerParameters() const {
|
||||
return headerParams_;
|
||||
}
|
||||
|
||||
void CommonRequest::setHeaderParameter(const ParameterNameType &name, const ParameterValueType &value)
|
||||
{
|
||||
void CommonRequest::setHeaderParameter(const ParameterNameType &name,
|
||||
const ParameterValueType &value) {
|
||||
headerParams_[name] = value;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,23 +16,21 @@
|
||||
|
||||
#include <alibabacloud/core/CommonResponse.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
CommonResponse::CommonResponse() :
|
||||
payload_()
|
||||
{
|
||||
payload_() {
|
||||
}
|
||||
|
||||
CommonResponse::CommonResponse(const std::string &payload) :
|
||||
payload_(payload)
|
||||
{
|
||||
payload_(payload) {
|
||||
}
|
||||
|
||||
CommonResponse::~CommonResponse()
|
||||
{
|
||||
CommonResponse::~CommonResponse() {
|
||||
}
|
||||
|
||||
std::string CommonResponse::payload() const
|
||||
{
|
||||
std::string CommonResponse::payload() const {
|
||||
return payload_;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -25,50 +25,46 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
CoreClient::CoreClient(const std::string & servicename, const ClientConfiguration &configuration) :
|
||||
CoreClient::CoreClient(const std::string & servicename,
|
||||
const ClientConfiguration &configuration) :
|
||||
serviceName_(servicename),
|
||||
configuration_(configuration),
|
||||
httpClient_(new CurlHttpClient)
|
||||
{
|
||||
httpClient_(new CurlHttpClient) {
|
||||
httpClient_->setProxy(configuration.proxy());
|
||||
}
|
||||
|
||||
CoreClient::~CoreClient()
|
||||
{
|
||||
CoreClient::~CoreClient() {
|
||||
delete httpClient_;
|
||||
}
|
||||
|
||||
ClientConfiguration CoreClient::configuration()const
|
||||
{
|
||||
ClientConfiguration CoreClient::configuration()const {
|
||||
return configuration_;
|
||||
}
|
||||
|
||||
std::string CoreClient::serviceName()const
|
||||
{
|
||||
std::string CoreClient::serviceName()const {
|
||||
return serviceName_;
|
||||
}
|
||||
|
||||
void CoreClient::asyncExecute(Runnable * r)const
|
||||
{
|
||||
void CoreClient::asyncExecute(Runnable * r)const {
|
||||
Executor::instance()->execute(r);
|
||||
}
|
||||
|
||||
HttpClient::HttpResponseOutcome CoreClient::AttemptRequest(const std::string & endpoint, const ServiceRequest & request, HttpRequest::Method method) const
|
||||
{
|
||||
HttpClient::HttpResponseOutcome CoreClient::AttemptRequest(
|
||||
const std::string & endpoint,
|
||||
const ServiceRequest & request, HttpRequest::Method method) const {
|
||||
auto r = buildHttpRequest(endpoint, request, method);
|
||||
auto outcome = httpClient_->makeRequest(r);
|
||||
if (!outcome.isSuccess())
|
||||
return outcome;
|
||||
if(hasResponseError(outcome.result()))
|
||||
if (hasResponseError(outcome.result()))
|
||||
return HttpClient::HttpResponseOutcome(buildCoreError(outcome.result()));
|
||||
else
|
||||
return outcome;
|
||||
}
|
||||
|
||||
Error CoreClient::buildCoreError(const HttpResponse &response)const
|
||||
{
|
||||
Error CoreClient::buildCoreError(const HttpResponse &response)const {
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
if (!reader.parse(std::string(response.body(), response.bodySize()), value))
|
||||
@@ -85,7 +81,8 @@ Error CoreClient::buildCoreError(const HttpResponse &response)const
|
||||
return error;
|
||||
}
|
||||
|
||||
bool CoreClient::hasResponseError(const HttpResponse &response)const
|
||||
{
|
||||
bool CoreClient::hasResponseError(const HttpResponse &response)const {
|
||||
return response.statusCode() < 200 || response.statusCode() > 299;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,47 +16,41 @@
|
||||
|
||||
#include <alibabacloud/core/Credentials.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
Credentials::Credentials(const std::string &accessKeyId,
|
||||
const std::string &accessKeySecret,
|
||||
const std::string &sessionToken) :
|
||||
accessKeyId_(accessKeyId),
|
||||
accessKeySecret_(accessKeySecret),
|
||||
sessionToken_(sessionToken)
|
||||
{
|
||||
sessionToken_(sessionToken) {
|
||||
}
|
||||
|
||||
Credentials::~Credentials()
|
||||
{
|
||||
Credentials::~Credentials() {
|
||||
}
|
||||
|
||||
std::string Credentials::accessKeyId () const
|
||||
{
|
||||
std::string Credentials::accessKeyId() const {
|
||||
return accessKeyId_;
|
||||
}
|
||||
|
||||
std::string Credentials::accessKeySecret () const
|
||||
{
|
||||
std::string Credentials::accessKeySecret() const {
|
||||
return accessKeySecret_;
|
||||
}
|
||||
|
||||
void Credentials::setAccessKeyId(const std::string &accessKeyId)
|
||||
{
|
||||
void Credentials::setAccessKeyId(const std::string &accessKeyId) {
|
||||
accessKeyId_ = accessKeyId;
|
||||
}
|
||||
|
||||
void Credentials::setAccessKeySecret(const std::string &accessKeySecret)
|
||||
{
|
||||
void Credentials::setAccessKeySecret(const std::string &accessKeySecret) {
|
||||
accessKeySecret_ = accessKeySecret;
|
||||
}
|
||||
|
||||
void Credentials::setSessionToken (const std::string &sessionToken)
|
||||
{
|
||||
void Credentials::setSessionToken(const std::string &sessionToken) {
|
||||
sessionToken_ = sessionToken;
|
||||
}
|
||||
|
||||
std::string Credentials::sessionToken () const
|
||||
{
|
||||
std::string Credentials::sessionToken() const {
|
||||
return sessionToken_;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -17,85 +17,77 @@
|
||||
#include "CurlHttpClient.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
namespace
|
||||
{
|
||||
size_t recvBody(char *ptr, size_t size, size_t nmemb, void *userdata)
|
||||
{
|
||||
std::ostringstream &out = *static_cast<std::ostringstream*>(userdata);
|
||||
out << std::string(ptr, nmemb*size);
|
||||
return nmemb * size;
|
||||
namespace {
|
||||
size_t recvBody(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
||||
std::ostringstream &out = *static_cast<std::ostringstream*>(userdata);
|
||||
out << std::string(ptr, nmemb*size);
|
||||
return nmemb * size;
|
||||
}
|
||||
|
||||
size_t recvHeaders(char *buffer, size_t size, size_t nitems, void *userdata) {
|
||||
HttpResponse *response = static_cast<HttpResponse*>(userdata);
|
||||
std::string line(buffer);
|
||||
auto pos = line.find(':');
|
||||
if (pos != line.npos) {
|
||||
std::string name = line.substr(0, pos);
|
||||
std::string value = line.substr(pos + 2);
|
||||
size_t p = 0;
|
||||
if ((p = value.rfind('\r')) != value.npos)
|
||||
value[p] = '\0';
|
||||
response->setHeader(name, value);
|
||||
}
|
||||
return nitems * size;
|
||||
}
|
||||
|
||||
size_t recvHeaders(char *buffer, size_t size, size_t nitems, void *userdata)
|
||||
{
|
||||
HttpResponse *response = static_cast<HttpResponse*>(userdata);
|
||||
std::string line(buffer);
|
||||
auto pos = line.find(':');
|
||||
if (pos != line.npos)
|
||||
{
|
||||
std::string name = line.substr(0, pos);
|
||||
std::string value = line.substr(pos + 2);
|
||||
size_t p = 0;
|
||||
if ((p = value.rfind('\r')) != value.npos)
|
||||
value[p] = '\0';
|
||||
response->setHeader(name, value);
|
||||
}
|
||||
return nitems * size;
|
||||
void setCUrlProxy(CURL *curlHandle, const NetworkProxy &proxy) {
|
||||
if (proxy.type() == NetworkProxy::Type::None)
|
||||
return;
|
||||
|
||||
long type;
|
||||
switch (proxy.type()) {
|
||||
case NetworkProxy::Type::Socks5:
|
||||
type = CURLPROXY_SOCKS5;
|
||||
break;
|
||||
case NetworkProxy::Type::Http:
|
||||
default:
|
||||
type = CURLPROXY_HTTP;
|
||||
break;
|
||||
}
|
||||
curl_easy_setopt(curlHandle, CURLOPT_PROXYTYPE, type);
|
||||
|
||||
void setCUrlProxy(CURL *curlHandle, const NetworkProxy &proxy)
|
||||
{
|
||||
if (proxy.type() == NetworkProxy::Type::None)
|
||||
return;
|
||||
std::ostringstream out;
|
||||
out << proxy.hostName() << ":" << proxy.port();
|
||||
curl_easy_setopt(curlHandle, CURLOPT_PROXY, out.str().c_str());
|
||||
|
||||
long type;
|
||||
switch (proxy.type())
|
||||
{
|
||||
case NetworkProxy::Type::Socks5:
|
||||
type = CURLPROXY_SOCKS5;
|
||||
break;
|
||||
case NetworkProxy::Type::Http:
|
||||
default:
|
||||
type = CURLPROXY_HTTP;
|
||||
break;
|
||||
}
|
||||
curl_easy_setopt(curlHandle, CURLOPT_PROXYTYPE, type);
|
||||
|
||||
std::ostringstream out;
|
||||
out << proxy.hostName() << ":" << proxy.port();
|
||||
curl_easy_setopt(curlHandle, CURLOPT_PROXY, out.str().c_str());
|
||||
|
||||
if (!proxy.user().empty()) {
|
||||
out.clear();
|
||||
out << proxy.user() << ":" << proxy.password();
|
||||
curl_easy_setopt(curlHandle, CURLOPT_PROXYUSERPWD, out.str().c_str());
|
||||
}
|
||||
if (!proxy.user().empty()) {
|
||||
out.clear();
|
||||
out << proxy.user() << ":" << proxy.password();
|
||||
curl_easy_setopt(curlHandle, CURLOPT_PROXYUSERPWD, out.str().c_str());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
CurlHttpClient::CurlHttpClient() :
|
||||
HttpClient(),
|
||||
curlHandle_(curl_easy_init())
|
||||
{
|
||||
curlHandle_(curl_easy_init()) {
|
||||
}
|
||||
|
||||
CurlHttpClient::~CurlHttpClient()
|
||||
{
|
||||
CurlHttpClient::~CurlHttpClient() {
|
||||
curl_easy_cleanup(curlHandle_);
|
||||
}
|
||||
|
||||
HttpClient::HttpResponseOutcome CurlHttpClient::makeRequest(const HttpRequest &request)
|
||||
{
|
||||
HttpClient::HttpResponseOutcome
|
||||
CurlHttpClient::makeRequest(const HttpRequest &request) {
|
||||
curl_easy_reset(curlHandle_);
|
||||
HttpResponse response(request);
|
||||
|
||||
std::string url = request.url().toString();
|
||||
switch (request.method())
|
||||
{
|
||||
switch (request.method()) {
|
||||
case HttpRequest::Method::Get:
|
||||
break;
|
||||
case HttpRequest::Method::Post: {
|
||||
@@ -121,8 +113,7 @@ HttpClient::HttpResponseOutcome CurlHttpClient::makeRequest(const HttpRequest &r
|
||||
|
||||
curl_slist *list = nullptr;
|
||||
auto headers = request.headers();
|
||||
for (const auto &p : headers)
|
||||
{
|
||||
for (const auto &p : headers) {
|
||||
std::string str = p.first;
|
||||
str.append(": ").append(p.second);
|
||||
list = curl_slist_append(list, str.c_str());
|
||||
@@ -134,8 +125,7 @@ HttpClient::HttpResponseOutcome CurlHttpClient::makeRequest(const HttpRequest &r
|
||||
setCUrlProxy(curlHandle_, proxy());
|
||||
|
||||
CURLcode res = curl_easy_perform(curlHandle_);
|
||||
switch (res)
|
||||
{
|
||||
switch (res) {
|
||||
case CURLE_OK: {
|
||||
long response_code;
|
||||
curl_easy_getinfo(curlHandle_, CURLINFO_RESPONSE_CODE, &response_code);
|
||||
@@ -144,8 +134,13 @@ HttpClient::HttpResponseOutcome CurlHttpClient::makeRequest(const HttpRequest &r
|
||||
return HttpResponseOutcome(response);
|
||||
}
|
||||
case CURLE_SSL_CONNECT_ERROR:
|
||||
return HttpResponseOutcome(Error("SSLConnectError", "A problem occurred somewhere in the SSL/TLS handshake."));
|
||||
return HttpResponseOutcome(
|
||||
Error("SSLConnectError",
|
||||
"A problem occurred somewhere in the SSL/TLS handshake."));
|
||||
default:
|
||||
return HttpResponseOutcome(Error("NetworkError", "Failed to connect to host or proxy."));
|
||||
return HttpResponseOutcome(
|
||||
Error("NetworkError", "Failed to connect to host or proxy."));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -14,24 +14,23 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_CURLHTTPCLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_CURLHTTPCLIENT_H_
|
||||
#ifndef CORE_SRC_CURLHTTPCLIENT_H_
|
||||
#define CORE_SRC_CURLHTTPCLIENT_H_
|
||||
|
||||
#include <alibabacloud/core/HttpClient.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class CurlHttpClient : public HttpClient
|
||||
{
|
||||
public:
|
||||
CurlHttpClient();
|
||||
~CurlHttpClient();
|
||||
namespace AlibabaCloud {
|
||||
class CurlHttpClient : public HttpClient {
|
||||
public:
|
||||
CurlHttpClient();
|
||||
~CurlHttpClient();
|
||||
|
||||
virtual HttpResponseOutcome makeRequest(const HttpRequest &request) override;
|
||||
private:
|
||||
CURL *curlHandle_;
|
||||
};
|
||||
}
|
||||
HttpResponseOutcome makeRequest(const HttpRequest &request) override;
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_CURLHTTPCLIENT_H_
|
||||
private:
|
||||
CURL *curlHandle_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // CORE_SRC_CURLHTTPCLIENT_H_
|
||||
|
||||
@@ -14,29 +14,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "EcsMetadataFetcher.h"
|
||||
#include <alibabacloud/core/Url.h>
|
||||
#include <sstream>
|
||||
#include <memory>
|
||||
#include <alibabacloud/core/Url.h>
|
||||
#include "EcsMetadataFetcher.h"
|
||||
#include "CurlHttpClient.h"
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
EcsMetadataFetcher::EcsMetadataFetcher()
|
||||
{
|
||||
EcsMetadataFetcher::EcsMetadataFetcher() {
|
||||
}
|
||||
|
||||
EcsMetadataFetcher::~EcsMetadataFetcher()
|
||||
{
|
||||
EcsMetadataFetcher::~EcsMetadataFetcher() {
|
||||
}
|
||||
|
||||
std::string EcsMetadataFetcher::roleName()const
|
||||
{
|
||||
std::string EcsMetadataFetcher::roleName()const {
|
||||
return roleName_;
|
||||
}
|
||||
|
||||
void EcsMetadataFetcher::setRoleName(const std::string & roleName)
|
||||
{
|
||||
void EcsMetadataFetcher::setRoleName(const std::string & roleName) {
|
||||
roleName_ = roleName;
|
||||
}
|
||||
|
||||
@@ -44,8 +40,8 @@ std::string EcsMetadataFetcher::getMetadata() {
|
||||
return getMetadata(METADATA_SERVICE_HOST, URL_IN_ECS_METADATA);
|
||||
}
|
||||
|
||||
std::string EcsMetadataFetcher::getMetadata(const std::string host, const std::string in_path)
|
||||
{
|
||||
std::string EcsMetadataFetcher::getMetadata(const std::string host,
|
||||
const std::string in_path) {
|
||||
std::stringstream path;
|
||||
path << in_path << roleName_;
|
||||
|
||||
@@ -64,3 +60,5 @@ std::string EcsMetadataFetcher::getMetadata(const std::string host, const std::s
|
||||
else
|
||||
return outcome.error().errorCode();
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -14,32 +14,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ECSMETADATASERVICECREDENTIALSFETCHER_H_
|
||||
#define ALIBABACLOUD_CORE_ECSMETADATASERVICECREDENTIALSFETCHER_H_
|
||||
#ifndef CORE_SRC_ECSMETADATAFETCHER_H_
|
||||
#define CORE_SRC_ECSMETADATAFETCHER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
const int DEFAULT_TIMEOUT_IN_MILLISECONDS = 5000;
|
||||
const char* const METADATA_SERVICE_HOST = "100.100.100.200";
|
||||
const char* const URL_IN_ECS_METADATA = "/latest/meta-data/ram/security-credentials/";
|
||||
const char* const URL_IN_ECS_METADATA =
|
||||
"/latest/meta-data/ram/security-credentials/";
|
||||
}
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class EcsMetadataFetcher
|
||||
{
|
||||
public:
|
||||
EcsMetadataFetcher();
|
||||
~EcsMetadataFetcher();
|
||||
namespace AlibabaCloud {
|
||||
class EcsMetadataFetcher {
|
||||
public:
|
||||
EcsMetadataFetcher();
|
||||
~EcsMetadataFetcher();
|
||||
|
||||
std::string roleName()const;
|
||||
void setRoleName(const std::string & roleName);
|
||||
std::string getMetadata(const std::string host, const std::string path);
|
||||
virtual std::string getMetadata();
|
||||
private:
|
||||
std::string roleName_;
|
||||
};
|
||||
}
|
||||
std::string roleName()const;
|
||||
void setRoleName(const std::string & roleName);
|
||||
std::string getMetadata(const std::string host, const std::string path);
|
||||
virtual std::string getMetadata();
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_ECSMETADATASERVICECREDENTIALSFETCHER_H_
|
||||
private:
|
||||
std::string roleName_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // CORE_SRC_ECSMETADATAFETCHER_H_
|
||||
|
||||
@@ -15,15 +15,13 @@
|
||||
*/
|
||||
|
||||
#include <alibabacloud/core/EndpointProvider.h>
|
||||
#include <json/json.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Location;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
#if defined(WIN32) && defined(_MSC_VER)
|
||||
# define strcasecmp _stricmp
|
||||
# define strncasecmp _strnicmp
|
||||
@@ -31,58 +29,62 @@ namespace
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
const std::string INTERNAL_ENDPOINTS_DATA = "{\"products\":["
|
||||
"{\"code\":\"aegis\",\"document_id\":\"28449\",\"location_service_code\":\"vipaegis\",\"regional_endpoints\":[],\"global_endpoint\":\"aegis.cn-hangzhou.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"alidns\",\"document_id\":\"29739\",\"location_service_code\":\"alidns\",\"regional_endpoints\":[],\"global_endpoint\":\"alidns.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"arms\",\"document_id\":\"42924\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"ap-southeast-1\",\"endpoint\":\"arms.ap-southeast-1.aliyuncs.com\"},{\"region\":\"cn-beijing\",\"endpoint\":\"arms.cn-beijing.aliyuncs.com\"},{\"region\":\"cn-hangzhou\",\"endpoint\":\"arms.cn-hangzhou.aliyuncs.com\"},{\"region\":\"cn-hongkong\",\"endpoint\":\"arms.cn-hongkong.aliyuncs.com\"},{\"region\":\"cn-qingdao\",\"endpoint\":\"arms.cn-qingdao.aliyuncs.com\"},{\"region\":\"cn-shanghai\",\"endpoint\":\"arms.cn-shanghai.aliyuncs.com\"},{\"region\":\"cn-shenzhen\",\"endpoint\":\"arms.cn-shenzhen.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"arms.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"batchcompute\",\"document_id\":\"44717\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"ap-southeast-1\",\"endpoint\":\"batchcompute.ap-southeast-1.aliyuncs.com\"},{\"region\":\"cn-beijing\",\"endpoint\":\"batchcompute.cn-beijing.aliyuncs.com\"},{\"region\":\"cn-hangzhou\",\"endpoint\":\"batchcompute.cn-hangzhou.aliyuncs.com\"},{\"region\":\"cn-huhehaote\",\"endpoint\":\"batchcompute.cn-huhehaote.aliyuncs.com\"},{\"region\":\"cn-qingdao\",\"endpoint\":\"batchcompute.cn-qingdao.aliyuncs.com\"},{\"region\":\"cn-shanghai\",\"endpoint\":\"batchcompute.cn-shanghai.aliyuncs.com\"},{\"region\":\"cn-shenzhen\",\"endpoint\":\"batchcompute.cn-shenzhen.aliyuncs.com\"},{\"region\":\"cn-zhangjiakou\",\"endpoint\":\"batchcompute.cn-zhangjiakou.aliyuncs.com\"},{\"region\":\"us-west-1\",\"endpoint\":\"batchcompute.us-west-1.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"batchcompute.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"ccc\",\"document_id\":\"63027\",\"location_service_code\":\"ccc\",\"regional_endpoints\":[{\"region\":\"cn-hangzhou\",\"endpoint\":\"ccc.cn-hangzhou.aliyuncs.com\"},{\"region\":\"cn-shanghai\",\"endpoint\":\"ccc.cn-shanghai.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"ccc.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"cdn\",\"document_id\":\"27148\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cdn.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cds\",\"document_id\":\"62887\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cds.cn-beijing.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"chatbot\",\"document_id\":\"60760\",\"location_service_code\":\"beebot\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"chatbot.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"cloudapi\",\"document_id\":\"43590\",\"location_service_code\":\"apigateway\",\"regional_endpoints\":[{\"region\":\"ap-northeast-1\",\"endpoint\":\"apigateway.ap-northeast-1.aliyuncs.com\"},{\"region\":\"us-west-1\",\"endpoint\":\"apigateway.us-west-1.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"apigateway.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"cloudauth\",\"document_id\":\"60687\",\"location_service_code\":\"cloudauth\",\"regional_endpoints\":[],\"global_endpoint\":\"cloudauth.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cloudphoto\",\"document_id\":\"59902\",\"location_service_code\":\"cloudphoto\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"cloudphoto.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"cloudwf\",\"document_id\":\"58111\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cloudwf.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cms\",\"document_id\":\"28615\",\"location_service_code\":\"cms\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cr\",\"document_id\":\"60716\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cr.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cs\",\"document_id\":\"26043\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cs.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"csb\",\"document_id\":\"64837\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"cn-beijing\",\"endpoint\":\"csb.cn-beijing.aliyuncs.com\"},{\"region\":\"cn-hangzhou\",\"endpoint\":\"csb.cn-hangzhou.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"csb.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"dds\",\"document_id\":\"61715\",\"location_service_code\":\"dds\",\"regional_endpoints\":[],\"global_endpoint\":\"mongodb.aliyuncs.com\",\"regional_endpoint_pattern\":\"mongodb.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"dm\",\"document_id\":\"29434\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"ap-southeast-1\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"ap-southeast-2\",\"endpoint\":\"dm.ap-southeast-2.aliyuncs.com\"},{\"region\":\"cn-beijing\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-hangzhou\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-hongkong\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-qingdao\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-shanghai\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-shenzhen\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"us-east-1\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"us-west-1\",\"endpoint\":\"dm.aliyuncs.com\"}],\"global_endpoint\":\"dm.aliyuncs.com\",\"regional_endpoint_pattern\":\"dm.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"domain\",\"document_id\":\"42875\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"domain.aliyuncs.com\",\"regional_endpoint_pattern\":\"domain.aliyuncs.com\"},"
|
||||
"{\"code\":\"domain-intl\",\"document_id\":\"\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"domain-intl.aliyuncs.com\",\"regional_endpoint_pattern\":\"domain-intl.aliyuncs.com\"},"
|
||||
"{\"code\":\"drds\",\"document_id\":\"51111\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"drds.aliyuncs.com\",\"regional_endpoint_pattern\":\"drds.aliyuncs.com\"},"
|
||||
"{\"code\":\"ecs\",\"document_id\":\"25484\",\"location_service_code\":\"ecs\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"emr\",\"document_id\":\"28140\",\"location_service_code\":\"emr\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"emr.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"ess\",\"document_id\":\"25925\",\"location_service_code\":\"ess\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"ess.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"green\",\"document_id\":\"28427\",\"location_service_code\":\"green\",\"regional_endpoints\":[],\"global_endpoint\":\"green.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"hpc\",\"document_id\":\"35201\",\"location_service_code\":\"hpc\",\"regional_endpoints\":[],\"global_endpoint\":\"hpc.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"httpdns\",\"document_id\":\"52679\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"httpdns-api.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"iot\",\"document_id\":\"30557\",\"location_service_code\":\"iot\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"iot.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"itaas\",\"document_id\":\"55759\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"itaas.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"jaq\",\"document_id\":\"35037\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"jaq.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"live\",\"document_id\":\"48207\",\"location_service_code\":\"live\",\"regional_endpoints\":[],\"global_endpoint\":\"live.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"mts\",\"document_id\":\"29212\",\"location_service_code\":\"mts\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"nas\",\"document_id\":\"62598\",\"location_service_code\":\"nas\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"ons\",\"document_id\":\"44416\",\"location_service_code\":\"ons\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"polardb\",\"document_id\":\"58764\",\"location_service_code\":\"polardb\",\"regional_endpoints\":[{\"region\":\"ap-south-1\",\"endpoint\":\"polardb.ap-south-1.aliyuncs.com\"},{\"region\":\"ap-southeast-5\",\"endpoint\":\"polardb.ap-southeast-5.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"polardb.aliyuncs.com\"},"
|
||||
"{\"code\":\"push\",\"document_id\":\"30074\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cloudpush.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"qualitycheck\",\"document_id\":\"50807\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"cn-hangzhou\",\"endpoint\":\"qualitycheck.cn-hangzhou.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"r-kvstore\",\"document_id\":\"60831\",\"location_service_code\":\"redisa\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"ram\",\"document_id\":\"28672\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"ram.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"rds\",\"document_id\":\"26223\",\"location_service_code\":\"rds\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"ros\",\"document_id\":\"28899\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"ros.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"sas-api\",\"document_id\":\"28498\",\"location_service_code\":\"sas\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"slb\",\"document_id\":\"27565\",\"location_service_code\":\"slb\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"sts\",\"document_id\":\"28756\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"sts.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"vod\",\"document_id\":\"60574\",\"location_service_code\":\"vod\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"vpc\",\"document_id\":\"34962\",\"location_service_code\":\"vpc\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"waf\",\"document_id\":\"62847\",\"location_service_code\":\"waf\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"}"
|
||||
"]}";
|
||||
}
|
||||
const std::string INTERNAL_ENDPOINTS_DATA = "{\"products\":["
|
||||
"{\"code\":\"aegis\",\"document_id\":\"28449\",\"location_service_code\":\"vipaegis\",\"regional_endpoints\":[],\"global_endpoint\":\"aegis.cn-hangzhou.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"alidns\",\"document_id\":\"29739\",\"location_service_code\":\"alidns\",\"regional_endpoints\":[],\"global_endpoint\":\"alidns.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"arms\",\"document_id\":\"42924\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"ap-southeast-1\",\"endpoint\":\"arms.ap-southeast-1.aliyuncs.com\"},{\"region\":\"cn-beijing\",\"endpoint\":\"arms.cn-beijing.aliyuncs.com\"},{\"region\":\"cn-hangzhou\",\"endpoint\":\"arms.cn-hangzhou.aliyuncs.com\"},{\"region\":\"cn-hongkong\",\"endpoint\":\"arms.cn-hongkong.aliyuncs.com\"},{\"region\":\"cn-qingdao\",\"endpoint\":\"arms.cn-qingdao.aliyuncs.com\"},{\"region\":\"cn-shanghai\",\"endpoint\":\"arms.cn-shanghai.aliyuncs.com\"},{\"region\":\"cn-shenzhen\",\"endpoint\":\"arms.cn-shenzhen.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"arms.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"batchcompute\",\"document_id\":\"44717\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"ap-southeast-1\",\"endpoint\":\"batchcompute.ap-southeast-1.aliyuncs.com\"},{\"region\":\"cn-beijing\",\"endpoint\":\"batchcompute.cn-beijing.aliyuncs.com\"},{\"region\":\"cn-hangzhou\",\"endpoint\":\"batchcompute.cn-hangzhou.aliyuncs.com\"},{\"region\":\"cn-huhehaote\",\"endpoint\":\"batchcompute.cn-huhehaote.aliyuncs.com\"},{\"region\":\"cn-qingdao\",\"endpoint\":\"batchcompute.cn-qingdao.aliyuncs.com\"},{\"region\":\"cn-shanghai\",\"endpoint\":\"batchcompute.cn-shanghai.aliyuncs.com\"},{\"region\":\"cn-shenzhen\",\"endpoint\":\"batchcompute.cn-shenzhen.aliyuncs.com\"},{\"region\":\"cn-zhangjiakou\",\"endpoint\":\"batchcompute.cn-zhangjiakou.aliyuncs.com\"},{\"region\":\"us-west-1\",\"endpoint\":\"batchcompute.us-west-1.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"batchcompute.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"ccc\",\"document_id\":\"63027\",\"location_service_code\":\"ccc\",\"regional_endpoints\":[{\"region\":\"cn-hangzhou\",\"endpoint\":\"ccc.cn-hangzhou.aliyuncs.com\"},{\"region\":\"cn-shanghai\",\"endpoint\":\"ccc.cn-shanghai.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"ccc.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"cdn\",\"document_id\":\"27148\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cdn.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cds\",\"document_id\":\"62887\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cds.cn-beijing.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"chatbot\",\"document_id\":\"60760\",\"location_service_code\":\"beebot\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"chatbot.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"cloudapi\",\"document_id\":\"43590\",\"location_service_code\":\"apigateway\",\"regional_endpoints\":[{\"region\":\"ap-northeast-1\",\"endpoint\":\"apigateway.ap-northeast-1.aliyuncs.com\"},{\"region\":\"us-west-1\",\"endpoint\":\"apigateway.us-west-1.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"apigateway.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"cloudauth\",\"document_id\":\"60687\",\"location_service_code\":\"cloudauth\",\"regional_endpoints\":[],\"global_endpoint\":\"cloudauth.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cloudphoto\",\"document_id\":\"59902\",\"location_service_code\":\"cloudphoto\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"cloudphoto.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"cloudwf\",\"document_id\":\"58111\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cloudwf.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cms\",\"document_id\":\"28615\",\"location_service_code\":\"cms\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cr\",\"document_id\":\"60716\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cr.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"cs\",\"document_id\":\"26043\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cs.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"csb\",\"document_id\":\"64837\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"cn-beijing\",\"endpoint\":\"csb.cn-beijing.aliyuncs.com\"},{\"region\":\"cn-hangzhou\",\"endpoint\":\"csb.cn-hangzhou.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"csb.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"dds\",\"document_id\":\"61715\",\"location_service_code\":\"dds\",\"regional_endpoints\":[],\"global_endpoint\":\"mongodb.aliyuncs.com\",\"regional_endpoint_pattern\":\"mongodb.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"dm\",\"document_id\":\"29434\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"ap-southeast-1\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"ap-southeast-2\",\"endpoint\":\"dm.ap-southeast-2.aliyuncs.com\"},{\"region\":\"cn-beijing\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-hangzhou\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-hongkong\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-qingdao\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-shanghai\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"cn-shenzhen\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"us-east-1\",\"endpoint\":\"dm.aliyuncs.com\"},{\"region\":\"us-west-1\",\"endpoint\":\"dm.aliyuncs.com\"}],\"global_endpoint\":\"dm.aliyuncs.com\",\"regional_endpoint_pattern\":\"dm.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"domain\",\"document_id\":\"42875\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"domain.aliyuncs.com\",\"regional_endpoint_pattern\":\"domain.aliyuncs.com\"},"
|
||||
"{\"code\":\"domain-intl\",\"document_id\":\"\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"domain-intl.aliyuncs.com\",\"regional_endpoint_pattern\":\"domain-intl.aliyuncs.com\"},"
|
||||
"{\"code\":\"drds\",\"document_id\":\"51111\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"drds.aliyuncs.com\",\"regional_endpoint_pattern\":\"drds.aliyuncs.com\"},"
|
||||
"{\"code\":\"ecs\",\"document_id\":\"25484\",\"location_service_code\":\"ecs\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"emr\",\"document_id\":\"28140\",\"location_service_code\":\"emr\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"emr.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"ess\",\"document_id\":\"25925\",\"location_service_code\":\"ess\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"ess.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"green\",\"document_id\":\"28427\",\"location_service_code\":\"green\",\"regional_endpoints\":[],\"global_endpoint\":\"green.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"hpc\",\"document_id\":\"35201\",\"location_service_code\":\"hpc\",\"regional_endpoints\":[],\"global_endpoint\":\"hpc.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"httpdns\",\"document_id\":\"52679\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"httpdns-api.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"iot\",\"document_id\":\"30557\",\"location_service_code\":\"iot\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"iot.[RegionId].aliyuncs.com\"},"
|
||||
"{\"code\":\"itaas\",\"document_id\":\"55759\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"itaas.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"jaq\",\"document_id\":\"35037\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"jaq.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"live\",\"document_id\":\"48207\",\"location_service_code\":\"live\",\"regional_endpoints\":[],\"global_endpoint\":\"live.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"mts\",\"document_id\":\"29212\",\"location_service_code\":\"mts\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"nas\",\"document_id\":\"62598\",\"location_service_code\":\"nas\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"ons\",\"document_id\":\"44416\",\"location_service_code\":\"ons\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"polardb\",\"document_id\":\"58764\",\"location_service_code\":\"polardb\",\"regional_endpoints\":[{\"region\":\"ap-south-1\",\"endpoint\":\"polardb.ap-south-1.aliyuncs.com\"},{\"region\":\"ap-southeast-5\",\"endpoint\":\"polardb.ap-southeast-5.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"polardb.aliyuncs.com\"},"
|
||||
"{\"code\":\"push\",\"document_id\":\"30074\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"cloudpush.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"qualitycheck\",\"document_id\":\"50807\",\"location_service_code\":\"\",\"regional_endpoints\":[{\"region\":\"cn-hangzhou\",\"endpoint\":\"qualitycheck.cn-hangzhou.aliyuncs.com\"}],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"r-kvstore\",\"document_id\":\"60831\",\"location_service_code\":\"redisa\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"ram\",\"document_id\":\"28672\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"ram.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"rds\",\"document_id\":\"26223\",\"location_service_code\":\"rds\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"ros\",\"document_id\":\"28899\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"ros.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"sas-api\",\"document_id\":\"28498\",\"location_service_code\":\"sas\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"slb\",\"document_id\":\"27565\",\"location_service_code\":\"slb\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"sts\",\"document_id\":\"28756\",\"location_service_code\":\"\",\"regional_endpoints\":[],\"global_endpoint\":\"sts.aliyuncs.com\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"vod\",\"document_id\":\"60574\",\"location_service_code\":\"vod\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"vpc\",\"document_id\":\"34962\",\"location_service_code\":\"vpc\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"},"
|
||||
"{\"code\":\"waf\",\"document_id\":\"62847\",\"location_service_code\":\"waf\",\"regional_endpoints\":[],\"global_endpoint\":\"\",\"regional_endpoint_pattern\":\"\"}"
|
||||
"]}";
|
||||
} // namespace
|
||||
|
||||
EndpointProvider::EndpointProvider(const std::shared_ptr<Location::LocationClient>& locationClient, const std::string regionId, const std::string product, const std::string serviceCode, int durationSeconds) :
|
||||
EndpointProvider::EndpointProvider(
|
||||
const std::shared_ptr<Location::LocationClient>& locationClient,
|
||||
const std::string regionId,
|
||||
const std::string product,
|
||||
const std::string serviceCode, int durationSeconds) :
|
||||
LocationClient(locationClient),
|
||||
regionId_(regionId),
|
||||
product_(product),
|
||||
@@ -91,8 +93,7 @@ EndpointProvider::EndpointProvider(const std::shared_ptr<Location::LocationClien
|
||||
cachedMutex_(),
|
||||
cachedEndpoint_(),
|
||||
expiry_(),
|
||||
internalProductsInfo_()
|
||||
{
|
||||
internalProductsInfo_() {
|
||||
loadInternalProductsInfo();
|
||||
}
|
||||
|
||||
@@ -112,25 +113,21 @@ EndpointProvider::EndpointProvider(
|
||||
cachedMutex_(),
|
||||
cachedEndpoint_(),
|
||||
expiry_(),
|
||||
internalProductsInfo_()
|
||||
{
|
||||
internalProductsInfo_() {
|
||||
loadInternalProductsInfo();
|
||||
}
|
||||
|
||||
EndpointProvider::~EndpointProvider()
|
||||
{
|
||||
EndpointProvider::~EndpointProvider() {
|
||||
}
|
||||
|
||||
bool EndpointProvider::loadInternalProductsInfo()
|
||||
{
|
||||
bool EndpointProvider::loadInternalProductsInfo() {
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
if (!reader.parse(INTERNAL_ENDPOINTS_DATA, value))
|
||||
return false;
|
||||
|
||||
auto productsNode = value["products"];
|
||||
for (auto value : productsNode)
|
||||
{
|
||||
for (auto value : productsNode) {
|
||||
Product p;
|
||||
p.code = value["code"].asString();
|
||||
p.documentId = value["document_id"].asString();
|
||||
@@ -139,8 +136,7 @@ bool EndpointProvider::loadInternalProductsInfo()
|
||||
p.regionalEndpointPattern = value["regional_endpoint_pattern"].asString();
|
||||
|
||||
auto regionalEndpointsNode = value["regional_endpoints"];
|
||||
for (auto value : regionalEndpointsNode)
|
||||
{
|
||||
for (auto value : regionalEndpointsNode) {
|
||||
p.regionalEndpoints.insert(std::make_pair(value["region"].asString(),
|
||||
value["endpoint"].asString()));
|
||||
}
|
||||
@@ -149,23 +145,21 @@ bool EndpointProvider::loadInternalProductsInfo()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EndpointProvider::checkExpiry()const
|
||||
{
|
||||
bool EndpointProvider::checkExpiry()const {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto diff = std::chrono::duration_cast<std::chrono::seconds>(now - expiry_).count();
|
||||
auto diff =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(now - expiry_).count();
|
||||
|
||||
return (diff > 0 - 60);
|
||||
}
|
||||
|
||||
std::string EndpointProvider::internalEndpoint(const std::string regionId, const std::string product)
|
||||
{
|
||||
for (Product p : internalProductsInfo_)
|
||||
{
|
||||
std::string EndpointProvider::internalEndpoint(const std::string regionId,
|
||||
const std::string product) {
|
||||
for (Product p : internalProductsInfo_) {
|
||||
if (strcasecmp(p.code.c_str(), product.c_str()) != 0)
|
||||
continue;
|
||||
|
||||
for (auto e : p.regionalEndpoints)
|
||||
{
|
||||
for (auto e : p.regionalEndpoints) {
|
||||
if (strcasecmp(e.first.c_str(), regionId.c_str()) != 0)
|
||||
continue;
|
||||
|
||||
@@ -176,13 +170,11 @@ std::string EndpointProvider::internalEndpoint(const std::string regionId, const
|
||||
return std::string();
|
||||
}
|
||||
|
||||
EndpointProvider::EndpointOutcome EndpointProvider::getEndpoint()
|
||||
{
|
||||
EndpointProvider::EndpointOutcome EndpointProvider::getEndpoint() {
|
||||
if (!configuration().endpoint().empty())
|
||||
return EndpointOutcome(configuration().endpoint());
|
||||
|
||||
if (!serviceCode_.empty())
|
||||
{
|
||||
if (!serviceCode_.empty()) {
|
||||
EndpointOutcome outcome = loadRemoteEndpoint();
|
||||
if (outcome.isSuccess())
|
||||
return outcome;
|
||||
@@ -195,17 +187,15 @@ EndpointProvider::EndpointOutcome EndpointProvider::getEndpoint()
|
||||
if (!endpoint.empty())
|
||||
return EndpointOutcome(endpoint);
|
||||
|
||||
return EndpointOutcome(Error("InvalidRegionId", "The specified region does not exist."));
|
||||
return EndpointOutcome(
|
||||
Error("InvalidRegionId", "The specified region does not exist."));
|
||||
}
|
||||
|
||||
EndpointProvider::EndpointOutcome EndpointProvider::loadRemoteEndpoint()
|
||||
{
|
||||
if (checkExpiry())
|
||||
{
|
||||
EndpointProvider::EndpointOutcome EndpointProvider::loadRemoteEndpoint() {
|
||||
if (checkExpiry()) {
|
||||
std::lock_guard<std::mutex> locker(cachedMutex_);
|
||||
if (checkExpiry())
|
||||
{
|
||||
Model::DescribeEndpointsRequest request;
|
||||
if (checkExpiry()) {
|
||||
Location::Model::DescribeEndpointsRequest request;
|
||||
request.setId(regionId_);
|
||||
request.setServiceCode(serviceCode_);
|
||||
request.setType("openAPI");
|
||||
@@ -224,3 +214,5 @@ EndpointProvider::EndpointOutcome EndpointProvider::loadRemoteEndpoint()
|
||||
|
||||
return EndpointOutcome(cachedEndpoint_);
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,15 +16,14 @@
|
||||
|
||||
#include <alibabacloud/core/Error.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
Error::Error(std::string code, const std::string message) :
|
||||
errorCode_(code),
|
||||
message_(message),
|
||||
host_(),
|
||||
requestId_(),
|
||||
detail_()
|
||||
{
|
||||
detail_() {
|
||||
}
|
||||
|
||||
std::string Error::errorCode()const { return errorCode_; }
|
||||
@@ -36,4 +35,6 @@ void Error::setErrorCode(const std::string &code) { errorCode_ = code; }
|
||||
void Error::setErrorMessage(const std::string& message) { message_ = message; }
|
||||
void Error::setHost(const std::string& host) { host_ = host; }
|
||||
void Error::setRequestId(const std::string& request) { requestId_ = request; }
|
||||
void Error::setDetail(const std::string& detail) { detail_ = detail; }
|
||||
void Error::setDetail(const std::string& detail) { detail_ = detail; }
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "Executor.h"
|
||||
#include <alibabacloud/core/Runnable.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
Executor *Executor::self_ = nullptr;
|
||||
|
||||
@@ -26,38 +26,30 @@ Executor::Executor() :
|
||||
shutdown_(true),
|
||||
tasksQueue_(),
|
||||
tasksQueueMutex_(),
|
||||
thread_()
|
||||
{
|
||||
thread_() {
|
||||
self_ = this;
|
||||
}
|
||||
|
||||
Executor::~Executor()
|
||||
{
|
||||
Executor::~Executor() {
|
||||
self_ = nullptr;
|
||||
shutdown();
|
||||
}
|
||||
|
||||
Executor * Executor::instance()
|
||||
{
|
||||
Executor * Executor::instance() {
|
||||
return self_;
|
||||
}
|
||||
|
||||
bool Executor::start()
|
||||
{
|
||||
bool Executor::start() {
|
||||
if (!isShutdown())
|
||||
return true;
|
||||
|
||||
auto threadMain = [this]()
|
||||
{
|
||||
while (!shutdown_)
|
||||
{
|
||||
while (!tasksQueue_.empty())
|
||||
{
|
||||
auto threadMain = [this]() {
|
||||
while (!shutdown_) {
|
||||
while (!tasksQueue_.empty()) {
|
||||
Runnable *task = nullptr;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(tasksQueueMutex_);
|
||||
if (!tasksQueue_.empty())
|
||||
{
|
||||
if (!tasksQueue_.empty()) {
|
||||
task = tasksQueue_.front();
|
||||
tasksQueue_.pop();
|
||||
}
|
||||
@@ -81,13 +73,11 @@ bool Executor::start()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Executor::isShutdown()const
|
||||
{
|
||||
bool Executor::isShutdown()const {
|
||||
return shutdown_;
|
||||
}
|
||||
|
||||
void Executor::execute(Runnable* task)
|
||||
{
|
||||
void Executor::execute(Runnable* task) {
|
||||
if (isShutdown())
|
||||
return;
|
||||
|
||||
@@ -96,14 +86,12 @@ void Executor::execute(Runnable* task)
|
||||
wakeUp();
|
||||
}
|
||||
|
||||
void Executor::wakeUp()
|
||||
{
|
||||
void Executor::wakeUp() {
|
||||
std::unique_lock<std::mutex> lk(cvMutex_);
|
||||
cv_.notify_one();
|
||||
}
|
||||
|
||||
void Executor::shutdown()
|
||||
{
|
||||
void Executor::shutdown() {
|
||||
if (isShutdown())
|
||||
return;
|
||||
|
||||
@@ -122,3 +110,5 @@ void Executor::shutdown()
|
||||
if (thread_.joinable())
|
||||
thread_.join();
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_EXECUTOR_H_
|
||||
#define ALIBABACLOUD_CORE_EXECUTOR_H_
|
||||
#ifndef CORE_SRC_EXECUTOR_H_
|
||||
#define CORE_SRC_EXECUTOR_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
@@ -24,30 +24,29 @@
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class Runnable;
|
||||
class Executor
|
||||
{
|
||||
public:
|
||||
Executor();
|
||||
~Executor();
|
||||
namespace AlibabaCloud {
|
||||
class Runnable;
|
||||
class Executor {
|
||||
public:
|
||||
Executor();
|
||||
~Executor();
|
||||
|
||||
static Executor * instance();
|
||||
void execute(Runnable* task);
|
||||
bool isShutdown()const;
|
||||
bool start();
|
||||
void shutdown();
|
||||
void wakeUp();
|
||||
private:
|
||||
static Executor *self_;
|
||||
std::atomic<bool> shutdown_;
|
||||
std::queue<Runnable*> tasksQueue_;
|
||||
std::mutex tasksQueueMutex_;
|
||||
std::thread thread_;
|
||||
std::condition_variable cv_;
|
||||
std::mutex cvMutex_;
|
||||
};
|
||||
}
|
||||
static Executor * instance();
|
||||
void execute(Runnable* task);
|
||||
bool isShutdown()const;
|
||||
bool start();
|
||||
void shutdown();
|
||||
void wakeUp();
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_EXECUTOR_H_
|
||||
private:
|
||||
static Executor *self_;
|
||||
std::atomic<bool> shutdown_;
|
||||
std::queue<Runnable*> tasksQueue_;
|
||||
std::mutex tasksQueueMutex_;
|
||||
std::thread thread_;
|
||||
std::condition_variable cv_;
|
||||
std::mutex cvMutex_;
|
||||
};
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
#endif // CORE_SRC_EXECUTOR_H_
|
||||
|
||||
@@ -22,19 +22,17 @@
|
||||
#include <openssl/hmac.h>
|
||||
#endif
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
HmacSha1Signer::HmacSha1Signer() :
|
||||
Signer(HmacSha1, "HMAC-SHA1", "1.0")
|
||||
{
|
||||
Signer(HmacSha1, "HMAC-SHA1", "1.0") {
|
||||
}
|
||||
|
||||
HmacSha1Signer::~HmacSha1Signer()
|
||||
{
|
||||
HmacSha1Signer::~HmacSha1Signer() {
|
||||
}
|
||||
|
||||
std::string HmacSha1Signer::generate(const std::string & src, const std::string & secret) const
|
||||
{
|
||||
std::string HmacSha1Signer::generate(const std::string & src,
|
||||
const std::string & secret) const {
|
||||
if (src.empty())
|
||||
return std::string();
|
||||
|
||||
@@ -46,7 +44,7 @@ std::string HmacSha1Signer::generate(const std::string & src, const std::string
|
||||
}my_blob;
|
||||
|
||||
DWORD kbLen = sizeof(my_blob) + secret.size();
|
||||
my_blob * kb = (my_blob *)LocalAlloc(LPTR, kbLen);
|
||||
my_blob * kb = reinterpret_cast<my_blob *>LocalAlloc(LPTR, kbLen);
|
||||
kb->hdr.bType = PLAINTEXTKEYBLOB;
|
||||
kb->hdr.bVersion = CUR_BLOB_VERSION;
|
||||
kb->hdr.reserved = 0;
|
||||
@@ -63,11 +61,14 @@ std::string HmacSha1Signer::generate(const std::string & src, const std::string
|
||||
ZeroMemory(&HmacInfo, sizeof(HmacInfo));
|
||||
HmacInfo.HashAlgid = CALG_SHA1;
|
||||
|
||||
CryptAcquireContext(&hProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_NEWKEYSET);
|
||||
CryptImportKey(hProv, (BYTE*)kb, kbLen, 0, CRYPT_IPSEC_HMAC_KEY, &hKey);
|
||||
CryptAcquireContext(&hProv, NULL,
|
||||
MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_NEWKEYSET);
|
||||
CryptImportKey(hProv,
|
||||
reinterpret_cast<BYTE*>(kb), kbLen, 0, CRYPT_IPSEC_HMAC_KEY, &hKey);
|
||||
CryptCreateHash(hProv, CALG_HMAC, hKey, 0, &hHmacHash);
|
||||
CryptSetHashParam(hHmacHash, HP_HMAC_INFO, (BYTE*)&HmacInfo, 0);
|
||||
CryptHashData(hHmacHash, (BYTE*)(src.c_str()), src.size(), 0);
|
||||
CryptSetHashParam(hHmacHash,
|
||||
HP_HMAC_INFO, reinterpret_cast<BYTE*>&HmacInfo, 0);
|
||||
CryptHashData(hHmacHash, reinterpret_cast<BYTE*>(src.c_str()), src.size(), 0);
|
||||
CryptGetHashParam(hHmacHash, HP_HASHVAL, pbHash, &dwDataLen, 0);
|
||||
|
||||
LocalFree(kb);
|
||||
@@ -76,9 +77,11 @@ std::string HmacSha1Signer::generate(const std::string & src, const std::string
|
||||
CryptReleaseContext(hProv, 0);
|
||||
|
||||
DWORD dlen = 0;
|
||||
CryptBinaryToString(pbHash, dwDataLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, NULL, &dlen);
|
||||
CryptBinaryToString(pbHash,
|
||||
dwDataLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, NULL, &dlen);
|
||||
char* dest = new char[dlen];
|
||||
CryptBinaryToString(pbHash, dwDataLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
|
||||
CryptBinaryToString(pbHash,
|
||||
dwDataLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
|
||||
|
||||
std::string ret = std::string(dest, dlen);
|
||||
delete dest;
|
||||
@@ -97,3 +100,5 @@ std::string HmacSha1Signer::generate(const std::string & src, const std::string
|
||||
return encodedData;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -19,23 +19,21 @@
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
HttpClient::HttpClient() :
|
||||
proxy_()
|
||||
{
|
||||
proxy_() {
|
||||
}
|
||||
|
||||
HttpClient::~HttpClient()
|
||||
{
|
||||
HttpClient::~HttpClient() {
|
||||
}
|
||||
|
||||
NetworkProxy HttpClient::proxy()const
|
||||
{
|
||||
NetworkProxy HttpClient::proxy()const {
|
||||
return proxy_;
|
||||
}
|
||||
|
||||
void HttpClient::setProxy(const NetworkProxy &proxy)
|
||||
{
|
||||
void HttpClient::setProxy(const NetworkProxy &proxy) {
|
||||
proxy_ = proxy;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
#include <alibabacloud/core/HttpMessage.h>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
#if defined(WIN32) && defined(_MSC_VER)
|
||||
# define strcasecmp _stricmp
|
||||
# define strncasecmp _strnicmp
|
||||
@@ -28,8 +27,7 @@ namespace
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
std::string KnownHeaderMapper[]
|
||||
{
|
||||
std::string KnownHeaderMapper[] {
|
||||
"Accept",
|
||||
"Accept-Charset",
|
||||
"Accept-Encoding",
|
||||
@@ -44,30 +42,26 @@ namespace
|
||||
"Server",
|
||||
"User-Agent"
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
HttpMessage::HttpMessage() :
|
||||
body_(nullptr),
|
||||
bodySize_(0),
|
||||
headers_()
|
||||
{
|
||||
headers_() {
|
||||
}
|
||||
|
||||
HttpMessage::HttpMessage(const HttpMessage &other) :
|
||||
body_(nullptr),
|
||||
bodySize_(other.bodySize_),
|
||||
headers_(other.headers_)
|
||||
{
|
||||
headers_(other.headers_) {
|
||||
setBody(other.body_, other.bodySize_);
|
||||
}
|
||||
|
||||
HttpMessage::HttpMessage(HttpMessage &&other)
|
||||
{
|
||||
HttpMessage::HttpMessage(HttpMessage &&other) {
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
HttpMessage& HttpMessage::operator=(const HttpMessage &other)
|
||||
{
|
||||
HttpMessage& HttpMessage::operator=(const HttpMessage &other) {
|
||||
if (this != &other) {
|
||||
body_ = nullptr;
|
||||
bodySize_ = 0;
|
||||
@@ -77,25 +71,23 @@ HttpMessage& HttpMessage::operator=(const HttpMessage &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
HttpMessage& HttpMessage::operator=(HttpMessage &&other)
|
||||
{
|
||||
HttpMessage& HttpMessage::operator=(HttpMessage &&other) {
|
||||
if (this != &other)
|
||||
*this = std::move(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void HttpMessage::addHeader(const HeaderNameType & name, const HeaderValueType & value)
|
||||
{
|
||||
void HttpMessage::addHeader(const HeaderNameType & name,
|
||||
const HeaderValueType & value) {
|
||||
setHeader(name, value);
|
||||
}
|
||||
|
||||
void HttpMessage::addHeader(KnownHeader header, const HeaderValueType & value)
|
||||
{
|
||||
void HttpMessage::addHeader(KnownHeader header, const HeaderValueType & value) {
|
||||
setHeader(header, value);
|
||||
}
|
||||
|
||||
HttpMessage::HeaderValueType HttpMessage::header(const HeaderNameType & name) const
|
||||
{
|
||||
HttpMessage::HeaderValueType HttpMessage::header(
|
||||
const HeaderNameType & name) const {
|
||||
auto it = headers_.find(name);
|
||||
if (it != headers_.end())
|
||||
return it->second;
|
||||
@@ -103,58 +95,49 @@ HttpMessage::HeaderValueType HttpMessage::header(const HeaderNameType & name) co
|
||||
return std::string();
|
||||
}
|
||||
|
||||
HttpMessage::HeaderCollection HttpMessage::headers() const
|
||||
{
|
||||
HttpMessage::HeaderCollection HttpMessage::headers() const {
|
||||
return headers_;
|
||||
}
|
||||
|
||||
void HttpMessage::removeHeader(const HeaderNameType & name)
|
||||
{
|
||||
void HttpMessage::removeHeader(const HeaderNameType & name) {
|
||||
headers_.erase(name);
|
||||
}
|
||||
|
||||
void HttpMessage::removeHeader(KnownHeader header)
|
||||
{
|
||||
void HttpMessage::removeHeader(KnownHeader header) {
|
||||
removeHeader(KnownHeaderMapper[header]);
|
||||
}
|
||||
|
||||
void HttpMessage::setHeader(const HeaderNameType & name, const HeaderValueType & value)
|
||||
{
|
||||
void HttpMessage::setHeader(const HeaderNameType & name,
|
||||
const HeaderValueType & value) {
|
||||
headers_[name] = value;
|
||||
}
|
||||
|
||||
void HttpMessage::setHeader(KnownHeader header, const std::string & value)
|
||||
{
|
||||
void HttpMessage::setHeader(KnownHeader header,
|
||||
const std::string & value) {
|
||||
setHeader(KnownHeaderMapper[header], value);
|
||||
}
|
||||
|
||||
HttpMessage::~HttpMessage()
|
||||
{
|
||||
HttpMessage::~HttpMessage() {
|
||||
setBody(nullptr, 0);
|
||||
}
|
||||
|
||||
const char* HttpMessage::body()const
|
||||
{
|
||||
const char* HttpMessage::body()const {
|
||||
return body_;
|
||||
}
|
||||
|
||||
size_t HttpMessage::bodySize()const
|
||||
{
|
||||
size_t HttpMessage::bodySize()const {
|
||||
return bodySize_;
|
||||
}
|
||||
|
||||
bool HttpMessage::hasBody() const
|
||||
{
|
||||
bool HttpMessage::hasBody() const {
|
||||
return (bodySize_ != 0);
|
||||
}
|
||||
|
||||
HttpMessage::HeaderValueType HttpMessage::header(KnownHeader header)const
|
||||
{
|
||||
HttpMessage::HeaderValueType HttpMessage::header(KnownHeader header)const {
|
||||
return this->header(KnownHeaderMapper[header]);
|
||||
}
|
||||
|
||||
void HttpMessage::setBody(const char *data, size_t size)
|
||||
{
|
||||
void HttpMessage::setBody(const char *data, size_t size) {
|
||||
if (body_)
|
||||
delete body_;
|
||||
body_ = nullptr;
|
||||
@@ -168,7 +151,8 @@ void HttpMessage::setBody(const char *data, size_t size)
|
||||
}
|
||||
|
||||
bool HttpMessage::nocaseLess::operator()(const std::string & s1,
|
||||
const std::string & s2) const
|
||||
{
|
||||
const std::string & s2) const {
|
||||
return strcasecmp(s1.c_str(), s2.c_str()) < 0;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,36 +16,32 @@
|
||||
|
||||
#include <alibabacloud/core/HttpRequest.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
HttpRequest::HttpRequest(const Url &url, Method method) :
|
||||
HttpMessage(),
|
||||
url_(url),
|
||||
method_(method)
|
||||
{
|
||||
method_(method) {
|
||||
}
|
||||
|
||||
HttpRequest::~HttpRequest()
|
||||
{
|
||||
HttpRequest::~HttpRequest() {
|
||||
}
|
||||
|
||||
HttpRequest::Method HttpRequest::method() const
|
||||
{
|
||||
HttpRequest::Method HttpRequest::method() const {
|
||||
return method_;
|
||||
}
|
||||
|
||||
|
||||
void HttpRequest::setMethod(Method method)
|
||||
{
|
||||
void HttpRequest::setMethod(Method method) {
|
||||
method_ = method;
|
||||
}
|
||||
|
||||
void HttpRequest::setUrl(const Url &url)
|
||||
{
|
||||
void HttpRequest::setUrl(const Url &url) {
|
||||
url_ = url;
|
||||
}
|
||||
|
||||
Url HttpRequest::url()const
|
||||
{
|
||||
Url HttpRequest::url()const {
|
||||
return url_;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,42 +16,37 @@
|
||||
|
||||
#include <alibabacloud/core/HttpResponse.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
#define INVALID_STATUS_CODE -1
|
||||
}
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
HttpResponse::HttpResponse() :
|
||||
HttpMessage(),
|
||||
request_(),
|
||||
statusCode_(INVALID_STATUS_CODE)
|
||||
{
|
||||
statusCode_(INVALID_STATUS_CODE) {
|
||||
}
|
||||
|
||||
HttpResponse::HttpResponse(const HttpRequest & request) :
|
||||
HttpMessage(),
|
||||
request_(request),
|
||||
statusCode_(INVALID_STATUS_CODE)
|
||||
{
|
||||
statusCode_(INVALID_STATUS_CODE) {
|
||||
}
|
||||
|
||||
HttpResponse::~HttpResponse()
|
||||
{
|
||||
HttpResponse::~HttpResponse() {
|
||||
}
|
||||
|
||||
HttpRequest HttpResponse::request() const
|
||||
{
|
||||
HttpRequest HttpResponse::request() const {
|
||||
return request_;
|
||||
}
|
||||
|
||||
void HttpResponse::setStatusCode(int code)
|
||||
{
|
||||
void HttpResponse::setStatusCode(int code) {
|
||||
statusCode_ = code;
|
||||
}
|
||||
|
||||
int HttpResponse::statusCode() const
|
||||
{
|
||||
int HttpResponse::statusCode() const {
|
||||
return statusCode_;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
#include <alibabacloud/core/InstanceProfileCredentials.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
InstanceProfileCredentials::InstanceProfileCredentials() :
|
||||
BasicSessionCredentials(Credentials::InstanceProfile)
|
||||
{
|
||||
BasicSessionCredentials(Credentials::InstanceProfile) {
|
||||
}
|
||||
|
||||
InstanceProfileCredentials::~InstanceProfileCredentials()
|
||||
{
|
||||
InstanceProfileCredentials::~InstanceProfileCredentials() {
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -15,65 +15,59 @@
|
||||
*/
|
||||
|
||||
#include <alibabacloud/core/InstanceProfileCredentialsProvider.h>
|
||||
#include <json/json.h>
|
||||
#include "EcsMetadataFetcher.h"
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <json/json.h>
|
||||
#include "EcsMetadataFetcher.h"
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
|
||||
InstanceProfileCredentialsProvider::InstanceProfileCredentialsProvider(const std::string & roleName, int durationSeconds):
|
||||
namespace AlibabaCloud {
|
||||
|
||||
InstanceProfileCredentialsProvider::InstanceProfileCredentialsProvider(
|
||||
const std::string & roleName, int durationSeconds):
|
||||
CredentialsProvider(),
|
||||
EcsMetadataFetcher(),
|
||||
durationSeconds_(durationSeconds),
|
||||
cachedMutex_(),
|
||||
cachedCredentials_("", ""),
|
||||
expiry_()
|
||||
{
|
||||
expiry_() {
|
||||
setRoleName(roleName);
|
||||
}
|
||||
|
||||
InstanceProfileCredentialsProvider::~InstanceProfileCredentialsProvider()
|
||||
{
|
||||
InstanceProfileCredentialsProvider::~InstanceProfileCredentialsProvider() {
|
||||
}
|
||||
|
||||
Credentials InstanceProfileCredentialsProvider::getCredentials()
|
||||
{
|
||||
Credentials InstanceProfileCredentialsProvider::getCredentials() {
|
||||
loadCredentials();
|
||||
std::lock_guard<std::mutex> locker(cachedMutex_);
|
||||
return cachedCredentials_;
|
||||
}
|
||||
|
||||
bool InstanceProfileCredentialsProvider::checkExpiry()const
|
||||
{
|
||||
bool InstanceProfileCredentialsProvider::checkExpiry()const {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto diff = std::chrono::duration_cast<std::chrono::seconds>(now - expiry_).count();
|
||||
auto diff =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(now - expiry_).count();
|
||||
|
||||
return (diff > 0 - 60);
|
||||
}
|
||||
|
||||
void InstanceProfileCredentialsProvider::loadCredentials()
|
||||
{
|
||||
if (checkExpiry())
|
||||
{
|
||||
void InstanceProfileCredentialsProvider::loadCredentials() {
|
||||
if (checkExpiry()) {
|
||||
std::lock_guard<std::mutex> locker(cachedMutex_);
|
||||
if (checkExpiry())
|
||||
{
|
||||
if (checkExpiry()) {
|
||||
auto outcome = getMetadata();
|
||||
Json::Value value;
|
||||
Json::Reader reader;
|
||||
if (reader.parse(outcome, value))
|
||||
{
|
||||
if (reader.parse(outcome, value)) {
|
||||
if (value["Code"].empty()
|
||||
&&value["AccessKeyId"].empty()
|
||||
&&value["AccessKeySecret"].empty()
|
||||
&&value["SecurityToken"].empty()
|
||||
&&value["Expiration"].empty())
|
||||
{
|
||||
cachedCredentials_ = Credentials("","");
|
||||
&&value["Expiration"].empty()) {
|
||||
cachedCredentials_ = Credentials("", "");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,3 +93,5 @@ void InstanceProfileCredentialsProvider::loadCredentials()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include <alibabacloud/core/NetworkProxy.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
NetworkProxy::NetworkProxy(Type type,
|
||||
const std::string &hostName,
|
||||
@@ -27,60 +27,50 @@ NetworkProxy::NetworkProxy(Type type,
|
||||
password_(password),
|
||||
port_(port),
|
||||
type_(type),
|
||||
user_(user)
|
||||
{
|
||||
user_(user) {
|
||||
}
|
||||
|
||||
NetworkProxy::~NetworkProxy()
|
||||
{
|
||||
NetworkProxy::~NetworkProxy() {
|
||||
}
|
||||
|
||||
std::string NetworkProxy::hostName() const
|
||||
{
|
||||
std::string NetworkProxy::hostName() const {
|
||||
return hostName_;
|
||||
}
|
||||
|
||||
std::string NetworkProxy::password() const
|
||||
{
|
||||
std::string NetworkProxy::password() const {
|
||||
return password_;
|
||||
}
|
||||
|
||||
uint16_t NetworkProxy::port() const
|
||||
{
|
||||
uint16_t NetworkProxy::port() const {
|
||||
return port_;
|
||||
}
|
||||
|
||||
void NetworkProxy::setHostName(const std::string &hostName)
|
||||
{
|
||||
void NetworkProxy::setHostName(const std::string &hostName) {
|
||||
hostName_ = hostName;
|
||||
}
|
||||
|
||||
void NetworkProxy::setPassword(const std::string &password)
|
||||
{
|
||||
void NetworkProxy::setPassword(const std::string &password) {
|
||||
password_ = password;
|
||||
}
|
||||
|
||||
void NetworkProxy::setPort(uint16_t port)
|
||||
{
|
||||
void NetworkProxy::setPort(uint16_t port) {
|
||||
port_ = port;
|
||||
}
|
||||
|
||||
void NetworkProxy::setType(NetworkProxy::Type type)
|
||||
{
|
||||
void NetworkProxy::setType(NetworkProxy::Type type) {
|
||||
type_ = type;
|
||||
}
|
||||
|
||||
void NetworkProxy::setUser(const std::string &user)
|
||||
{
|
||||
void NetworkProxy::setUser(const std::string &user) {
|
||||
user_ = user;
|
||||
}
|
||||
|
||||
NetworkProxy::Type NetworkProxy::type() const
|
||||
{
|
||||
NetworkProxy::Type NetworkProxy::type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
std::string NetworkProxy::user() const
|
||||
{
|
||||
std::string NetworkProxy::user() const {
|
||||
return user_;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -15,30 +15,29 @@
|
||||
*/
|
||||
|
||||
#include <alibabacloud/core/RoaServiceClient.h>
|
||||
#include <alibabacloud/core/HmacSha1Signer.h>
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <alibabacloud/core/HmacSha1Signer.h>
|
||||
//#include <alibabacloud/core/RoaErrorMarshaller.h>
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
RoaServiceClient::RoaServiceClient(const std::string & servicename, const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
RoaServiceClient::RoaServiceClient(const std::string & servicename,
|
||||
const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration,
|
||||
const std::shared_ptr<Signer> &signer) :
|
||||
CoreClient(servicename, configuration),
|
||||
credentialsProvider_(credentialsProvider),
|
||||
signer_(signer)
|
||||
{
|
||||
signer_(signer) {
|
||||
}
|
||||
|
||||
RoaServiceClient::~RoaServiceClient()
|
||||
{
|
||||
RoaServiceClient::~RoaServiceClient() {
|
||||
}
|
||||
|
||||
RoaServiceClient::JsonOutcome RoaServiceClient::makeRequest(const std::string &endpoint, const RoaServiceRequest &msg, HttpRequest::Method method)const
|
||||
{
|
||||
RoaServiceClient::JsonOutcome RoaServiceClient::makeRequest(
|
||||
const std::string &endpoint,
|
||||
const RoaServiceRequest &msg, HttpRequest::Method method)const {
|
||||
auto outcome = AttemptRequest(endpoint, msg, method);
|
||||
if (outcome.isSuccess())
|
||||
return JsonOutcome(std::string(outcome.result().body(),
|
||||
@@ -47,13 +46,14 @@ RoaServiceClient::JsonOutcome RoaServiceClient::makeRequest(const std::string &e
|
||||
return JsonOutcome(outcome.error());
|
||||
}
|
||||
|
||||
HttpRequest RoaServiceClient::buildHttpRequest(const std::string & endpoint, const ServiceRequest &msg, HttpRequest::Method method)const
|
||||
{
|
||||
return buildHttpRequest(endpoint, dynamic_cast<const RoaServiceRequest& >(msg), method);
|
||||
HttpRequest RoaServiceClient::buildHttpRequest(const std::string & endpoint,
|
||||
const ServiceRequest &msg, HttpRequest::Method method)const {
|
||||
return buildHttpRequest(endpoint,
|
||||
dynamic_cast<const RoaServiceRequest& >(msg), method);
|
||||
}
|
||||
|
||||
HttpRequest RoaServiceClient::buildHttpRequest(const std::string & endpoint, const RoaServiceRequest &msg, HttpRequest::Method method) const
|
||||
{
|
||||
HttpRequest RoaServiceClient::buildHttpRequest(const std::string & endpoint,
|
||||
const RoaServiceRequest &msg, HttpRequest::Method method) const {
|
||||
const Credentials credentials = credentialsProvider_->getCredentials();
|
||||
|
||||
Url url;
|
||||
@@ -74,8 +74,7 @@ HttpRequest RoaServiceClient::buildHttpRequest(const std::string & endpoint, con
|
||||
|
||||
if (!queryParams.empty()) {
|
||||
std::stringstream queryString;
|
||||
for (const auto &p : queryParams)
|
||||
{
|
||||
for (const auto &p : queryParams) {
|
||||
if (p.second.empty())
|
||||
queryString << "&" << p.first;
|
||||
else
|
||||
@@ -96,12 +95,13 @@ HttpRequest RoaServiceClient::buildHttpRequest(const std::string & endpoint, con
|
||||
std::stringstream ss;
|
||||
ss << msg.contentSize();
|
||||
request.setHeader("Content-Length", ss.str());
|
||||
if(msg.parameter("Content-Type").empty()) {
|
||||
if (msg.parameter("Content-Type").empty()) {
|
||||
request.setHeader("Content-Type", "application/octet-stream");
|
||||
} else {
|
||||
request.setHeader("Content-Type", msg.parameter("Content-Type"));
|
||||
}
|
||||
request.setHeader("Content-MD5", ComputeContentMD5(msg.content(),msg.contentSize()));
|
||||
request.setHeader("Content-MD5",
|
||||
ComputeContentMD5(msg.content(), msg.contentSize()));
|
||||
request.setBody(msg.content(), msg.contentSize());
|
||||
}
|
||||
|
||||
@@ -116,7 +116,8 @@ HttpRequest RoaServiceClient::buildHttpRequest(const std::string & endpoint, con
|
||||
#endif
|
||||
request.setHeader("Date", date.str());
|
||||
request.setHeader("Host", url.host());
|
||||
request.setHeader("x-sdk-client", std::string("CPP/").append(ALIBABACLOUD_VERSION_STR));
|
||||
request.setHeader("x-sdk-client",
|
||||
std::string("CPP/").append(ALIBABACLOUD_VERSION_STR));
|
||||
request.setHeader("x-acs-region-id", configuration().regionId());
|
||||
if (!credentials.sessionToken().empty())
|
||||
request.setHeader("x-acs-security-token", credentials.sessionToken());
|
||||
@@ -145,3 +146,5 @@ HttpRequest RoaServiceClient::buildHttpRequest(const std::string & endpoint, con
|
||||
request.setHeader("Authorization", sign.str());
|
||||
return request;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -20,13 +20,14 @@
|
||||
#include <sstream>
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
RoaServiceRequest::RoaServiceRequest(const std::string & product, const std::string & version) :
|
||||
ServiceRequest(product, version)
|
||||
{
|
||||
RoaServiceRequest::RoaServiceRequest(const std::string & product,
|
||||
const std::string & version) :
|
||||
ServiceRequest(product, version) {
|
||||
}
|
||||
|
||||
RoaServiceRequest::~RoaServiceRequest()
|
||||
{
|
||||
RoaServiceRequest::~RoaServiceRequest() {
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -15,29 +15,29 @@
|
||||
*/
|
||||
|
||||
#include <alibabacloud/core/RpcServiceClient.h>
|
||||
#include <alibabacloud/core/HmacSha1Signer.h>
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <alibabacloud/core/HmacSha1Signer.h>
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
RpcServiceClient::RpcServiceClient(const std::string & servicename, const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
RpcServiceClient::RpcServiceClient(const std::string & servicename,
|
||||
const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration,
|
||||
const std::shared_ptr<Signer> &signer) :
|
||||
CoreClient(servicename, configuration),
|
||||
credentialsProvider_(credentialsProvider),
|
||||
signer_(signer)
|
||||
{
|
||||
signer_(signer) {
|
||||
}
|
||||
|
||||
RpcServiceClient::~RpcServiceClient()
|
||||
{
|
||||
RpcServiceClient::~RpcServiceClient() {
|
||||
}
|
||||
|
||||
RpcServiceClient::JsonOutcome RpcServiceClient::makeRequest(const std::string &endpoint, const RpcServiceRequest &msg, HttpRequest::Method method)const
|
||||
{
|
||||
RpcServiceClient::JsonOutcome RpcServiceClient::makeRequest(
|
||||
const std::string &endpoint,
|
||||
const RpcServiceRequest &msg, HttpRequest::Method method)const {
|
||||
auto outcome = AttemptRequest(endpoint, msg, method);
|
||||
if (outcome.isSuccess())
|
||||
return JsonOutcome(std::string(outcome.result().body(),
|
||||
@@ -46,13 +46,14 @@ RpcServiceClient::JsonOutcome RpcServiceClient::makeRequest(const std::string &e
|
||||
return JsonOutcome(outcome.error());
|
||||
}
|
||||
|
||||
HttpRequest RpcServiceClient::buildHttpRequest(const std::string & endpoint, const ServiceRequest &msg, HttpRequest::Method method )const
|
||||
{
|
||||
return buildHttpRequest(endpoint, dynamic_cast<const RpcServiceRequest& >(msg), method);
|
||||
HttpRequest RpcServiceClient::buildHttpRequest(const std::string & endpoint,
|
||||
const ServiceRequest &msg, HttpRequest::Method method)const {
|
||||
return buildHttpRequest(endpoint,
|
||||
dynamic_cast<const RpcServiceRequest& >(msg), method);
|
||||
}
|
||||
|
||||
HttpRequest RpcServiceClient::buildHttpRequest(const std::string & endpoint, const RpcServiceRequest &msg, HttpRequest::Method method) const
|
||||
{
|
||||
HttpRequest RpcServiceClient::buildHttpRequest(const std::string & endpoint,
|
||||
const RpcServiceRequest &msg, HttpRequest::Method method) const {
|
||||
const Credentials credentials = credentialsProvider_->getCredentials();
|
||||
|
||||
Url url;
|
||||
@@ -97,7 +98,8 @@ HttpRequest RpcServiceClient::buildHttpRequest(const std::string & endpoint, con
|
||||
<< "&"
|
||||
<< UrlEncode(canonicalizedQuery(queryParams));
|
||||
|
||||
queryParams["Signature"] = signer_->generate(plaintext.str(), credentials.accessKeySecret() + "&");
|
||||
queryParams["Signature"] = signer_->generate(plaintext.str(),
|
||||
credentials.accessKeySecret() + "&");
|
||||
|
||||
std::stringstream queryString;
|
||||
for (const auto &p : queryParams)
|
||||
@@ -107,6 +109,9 @@ HttpRequest RpcServiceClient::buildHttpRequest(const std::string & endpoint, con
|
||||
HttpRequest request(url);
|
||||
request.setMethod(method);
|
||||
request.setHeader("Host", url.host());
|
||||
request.setHeader("x-sdk-client", std::string("CPP/").append(ALIBABACLOUD_VERSION_STR));
|
||||
request.setHeader("x-sdk-client",
|
||||
std::string("CPP/").append(ALIBABACLOUD_VERSION_STR));
|
||||
return request;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,25 +16,24 @@
|
||||
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
RpcServiceRequest::RpcServiceRequest(const std::string & product, const std::string & version, const std::string & action) :
|
||||
ServiceRequest(product, version)
|
||||
{
|
||||
RpcServiceRequest::RpcServiceRequest(const std::string & product,
|
||||
const std::string & version, const std::string & action) :
|
||||
ServiceRequest(product, version) {
|
||||
setActionName(action);
|
||||
}
|
||||
|
||||
RpcServiceRequest::~RpcServiceRequest()
|
||||
{
|
||||
RpcServiceRequest::~RpcServiceRequest() {
|
||||
}
|
||||
|
||||
std::string RpcServiceRequest::actionName()const
|
||||
{
|
||||
std::string RpcServiceRequest::actionName()const {
|
||||
return parameter("Action");
|
||||
}
|
||||
|
||||
|
||||
void RpcServiceRequest::setActionName(const std::string & name)
|
||||
{
|
||||
void RpcServiceRequest::setActionName(const std::string & name) {
|
||||
setParameter("Action", name);
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
#include <alibabacloud/core/Runnable.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
Runnable::Runnable(const std::function<void()> f) :
|
||||
f_(f)
|
||||
{
|
||||
f_(f) {
|
||||
}
|
||||
|
||||
void Runnable::run() const
|
||||
{
|
||||
void Runnable::run() const {
|
||||
f_();
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,17 +16,17 @@
|
||||
|
||||
#include <alibabacloud/core/ServiceRequest.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
ServiceRequest::ServiceRequest(const std::string &product, const std::string &version) :
|
||||
ServiceRequest::ServiceRequest(const std::string &product,
|
||||
const std::string &version) :
|
||||
content_(nullptr),
|
||||
contentSize_(0),
|
||||
params_(),
|
||||
product_(product),
|
||||
resourcePath_("/"),
|
||||
version_(version),
|
||||
scheme_("https")
|
||||
{
|
||||
scheme_("https") {
|
||||
}
|
||||
|
||||
ServiceRequest::ServiceRequest(const ServiceRequest &other) :
|
||||
@@ -36,18 +36,15 @@ ServiceRequest::ServiceRequest(const ServiceRequest &other) :
|
||||
product_(other.product_),
|
||||
resourcePath_(other.resourcePath_),
|
||||
version_(other.version_),
|
||||
scheme_(other.scheme_)
|
||||
{
|
||||
scheme_(other.scheme_) {
|
||||
setContent(other.content_, other.contentSize_);
|
||||
}
|
||||
|
||||
ServiceRequest::ServiceRequest(ServiceRequest &&other)
|
||||
{
|
||||
ServiceRequest::ServiceRequest(ServiceRequest &&other) {
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
ServiceRequest& ServiceRequest::operator=(const ServiceRequest &other)
|
||||
{
|
||||
ServiceRequest& ServiceRequest::operator=(const ServiceRequest &other) {
|
||||
if (this != &other) {
|
||||
content_ = nullptr;
|
||||
contentSize_ = 0;
|
||||
@@ -57,36 +54,30 @@ ServiceRequest& ServiceRequest::operator=(const ServiceRequest &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
ServiceRequest& ServiceRequest::operator=(ServiceRequest &&other)
|
||||
{
|
||||
ServiceRequest& ServiceRequest::operator=(ServiceRequest &&other) {
|
||||
if (this != &other)
|
||||
*this = std::move(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ServiceRequest::~ServiceRequest()
|
||||
{
|
||||
ServiceRequest::~ServiceRequest() {
|
||||
if (content_)
|
||||
delete content_;
|
||||
}
|
||||
|
||||
const char * ServiceRequest::content() const
|
||||
{
|
||||
const char * ServiceRequest::content() const {
|
||||
return content_;
|
||||
}
|
||||
|
||||
size_t ServiceRequest::contentSize() const
|
||||
{
|
||||
size_t ServiceRequest::contentSize() const {
|
||||
return contentSize_;
|
||||
}
|
||||
|
||||
bool ServiceRequest::hasContent() const
|
||||
{
|
||||
bool ServiceRequest::hasContent() const {
|
||||
return (contentSize_ != 0);
|
||||
}
|
||||
|
||||
void ServiceRequest::setContent(const char * data, size_t size)
|
||||
{
|
||||
void ServiceRequest::setContent(const char * data, size_t size) {
|
||||
if (content_)
|
||||
delete content_;
|
||||
content_ = nullptr;
|
||||
@@ -98,13 +89,13 @@ void ServiceRequest::setContent(const char * data, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceRequest::addParameter(const ParameterNameType & name, const ParameterValueType & value)
|
||||
{
|
||||
void ServiceRequest::addParameter(const ParameterNameType & name,
|
||||
const ParameterValueType & value) {
|
||||
setParameter(name, value);
|
||||
}
|
||||
|
||||
ServiceRequest::ParameterValueType ServiceRequest::parameter(const ParameterNameType &name)const
|
||||
{
|
||||
ServiceRequest::ParameterValueType ServiceRequest::parameter(
|
||||
const ParameterNameType &name)const {
|
||||
ParameterCollection::const_iterator it = params_.find(name);
|
||||
if (it == params_.end()) {
|
||||
return ParameterValueType("");
|
||||
@@ -112,53 +103,44 @@ ServiceRequest::ParameterValueType ServiceRequest::parameter(const ParameterName
|
||||
return it->second;
|
||||
}
|
||||
|
||||
ServiceRequest::ParameterCollection ServiceRequest::parameters() const
|
||||
{
|
||||
ServiceRequest::ParameterCollection ServiceRequest::parameters() const {
|
||||
return params_;
|
||||
}
|
||||
|
||||
void ServiceRequest::removeParameter(const ParameterNameType & name)
|
||||
{
|
||||
void ServiceRequest::removeParameter(const ParameterNameType & name) {
|
||||
params_.erase(name);
|
||||
}
|
||||
|
||||
void ServiceRequest::setParameter(const ParameterNameType &name, const ParameterValueType &value)
|
||||
{
|
||||
void ServiceRequest::setParameter(const ParameterNameType &name,
|
||||
const ParameterValueType &value) {
|
||||
params_[name] = value;
|
||||
}
|
||||
|
||||
void ServiceRequest::setParameters(const ParameterCollection & params)
|
||||
{
|
||||
void ServiceRequest::setParameters(const ParameterCollection & params) {
|
||||
params_ = params;
|
||||
}
|
||||
|
||||
std::string ServiceRequest::version()const
|
||||
{
|
||||
std::string ServiceRequest::version()const {
|
||||
return version_;
|
||||
}
|
||||
|
||||
void ServiceRequest::setVersion(const std::string &version)
|
||||
{
|
||||
void ServiceRequest::setVersion(const std::string &version) {
|
||||
version_ = version;
|
||||
}
|
||||
|
||||
std::string ServiceRequest::product() const
|
||||
{
|
||||
std::string ServiceRequest::product() const {
|
||||
return product_;
|
||||
}
|
||||
|
||||
void ServiceRequest::setProduct(const std::string & product)
|
||||
{
|
||||
void ServiceRequest::setProduct(const std::string & product) {
|
||||
product_ = product;
|
||||
}
|
||||
|
||||
std::string ServiceRequest::resourcePath() const
|
||||
{
|
||||
std::string ServiceRequest::resourcePath() const {
|
||||
return resourcePath_;
|
||||
}
|
||||
|
||||
void ServiceRequest::setResourcePath(const std::string & path)
|
||||
{
|
||||
void ServiceRequest::setResourcePath(const std::string & path) {
|
||||
resourcePath_ = path;
|
||||
}
|
||||
|
||||
@@ -169,3 +151,5 @@ void ServiceRequest::setScheme(const std::string scheme) {
|
||||
std::string ServiceRequest::scheme() const {
|
||||
return scheme_;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,23 +16,21 @@
|
||||
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
ServiceResult::ServiceResult() :
|
||||
requestId_()
|
||||
{
|
||||
requestId_() {
|
||||
}
|
||||
|
||||
ServiceResult::~ServiceResult()
|
||||
{
|
||||
ServiceResult::~ServiceResult() {
|
||||
}
|
||||
|
||||
std::string ServiceResult::requestId() const
|
||||
{
|
||||
std::string ServiceResult::requestId() const {
|
||||
return requestId_;
|
||||
}
|
||||
|
||||
void ServiceResult::setRequestId(const std::string & requestId)
|
||||
{
|
||||
void ServiceResult::setRequestId(const std::string & requestId) {
|
||||
requestId_ = requestId;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,30 +16,28 @@
|
||||
|
||||
#include <alibabacloud/core/Signer.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
Signer::Signer(Type type, const std::string & name, const std::string & version) :
|
||||
Signer::Signer(Type type, const std::string & name,
|
||||
const std::string & version) :
|
||||
type_(type),
|
||||
name_(name),
|
||||
version_(version)
|
||||
{
|
||||
version_(version) {
|
||||
}
|
||||
|
||||
Signer::~Signer()
|
||||
{
|
||||
Signer::~Signer() {
|
||||
}
|
||||
|
||||
std::string Signer::name() const
|
||||
{
|
||||
std::string Signer::name() const {
|
||||
return name_;
|
||||
}
|
||||
|
||||
Signer::Type Signer::type() const
|
||||
{
|
||||
Signer::Type Signer::type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
std::string Signer::version() const
|
||||
{
|
||||
std::string Signer::version() const {
|
||||
return version_;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -16,25 +16,25 @@
|
||||
|
||||
#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
SimpleCredentialsProvider::SimpleCredentialsProvider(const Credentials &credentials):
|
||||
SimpleCredentialsProvider::SimpleCredentialsProvider(
|
||||
const Credentials &credentials):
|
||||
CredentialsProvider(),
|
||||
credentials_(credentials)
|
||||
{
|
||||
credentials_(credentials) {
|
||||
}
|
||||
|
||||
SimpleCredentialsProvider::SimpleCredentialsProvider(const std::string & accessKeyId, const std::string & accessKeySecret) :
|
||||
SimpleCredentialsProvider::SimpleCredentialsProvider(
|
||||
const std::string & accessKeyId, const std::string & accessKeySecret) :
|
||||
CredentialsProvider(),
|
||||
credentials_(accessKeyId, accessKeySecret)
|
||||
{
|
||||
credentials_(accessKeyId, accessKeySecret) {
|
||||
}
|
||||
|
||||
SimpleCredentialsProvider::~SimpleCredentialsProvider()
|
||||
{
|
||||
SimpleCredentialsProvider::~SimpleCredentialsProvider() {
|
||||
}
|
||||
|
||||
Credentials SimpleCredentialsProvider::getCredentials()
|
||||
{
|
||||
Credentials SimpleCredentialsProvider::getCredentials() {
|
||||
return credentials_;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Sts;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
StsAssumeRoleCredentialsProvider::StsAssumeRoleCredentialsProvider(
|
||||
const Credentials &credentials,
|
||||
@@ -36,45 +35,38 @@ StsAssumeRoleCredentialsProvider::StsAssumeRoleCredentialsProvider(
|
||||
durationSeconds_(durationSeconds),
|
||||
cachedMutex_(),
|
||||
cachedCredentials_("", ""),
|
||||
expiry_()
|
||||
{
|
||||
expiry_() {
|
||||
}
|
||||
|
||||
StsAssumeRoleCredentialsProvider::~StsAssumeRoleCredentialsProvider()
|
||||
{
|
||||
StsAssumeRoleCredentialsProvider::~StsAssumeRoleCredentialsProvider() {
|
||||
}
|
||||
|
||||
Credentials StsAssumeRoleCredentialsProvider::getCredentials()
|
||||
{
|
||||
Credentials StsAssumeRoleCredentialsProvider::getCredentials() {
|
||||
loadCredentials();
|
||||
std::lock_guard<std::mutex> locker(cachedMutex_);
|
||||
return cachedCredentials_;
|
||||
}
|
||||
|
||||
bool StsAssumeRoleCredentialsProvider::checkExpiry()const
|
||||
{
|
||||
bool StsAssumeRoleCredentialsProvider::checkExpiry()const {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto diff = std::chrono::duration_cast<std::chrono::seconds>(now - expiry_).count();
|
||||
auto diff =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(now - expiry_).count();
|
||||
|
||||
return (diff > 0 - 60);
|
||||
}
|
||||
|
||||
void StsAssumeRoleCredentialsProvider::loadCredentials()
|
||||
{
|
||||
if (checkExpiry())
|
||||
{
|
||||
void StsAssumeRoleCredentialsProvider::loadCredentials() {
|
||||
if (checkExpiry()) {
|
||||
std::lock_guard<std::mutex> locker(cachedMutex_);
|
||||
if (checkExpiry())
|
||||
{
|
||||
Model::AssumeRoleRequest request;
|
||||
if (checkExpiry()) {
|
||||
Sts::Model::AssumeRoleRequest request;
|
||||
request.setRoleArn(roleArn_);
|
||||
request.setRoleSessionName(roleSessionName_);
|
||||
request.setPolicy(policy_);
|
||||
request.setDurationSeconds(durationSeconds_);
|
||||
|
||||
auto assumeRoleOutcome = assumeRole(request);
|
||||
if (assumeRoleOutcome.isSuccess())
|
||||
{
|
||||
if (assumeRoleOutcome.isSuccess()) {
|
||||
const auto stsCredentials = assumeRoleOutcome.result().credentials();
|
||||
cachedCredentials_ = Credentials(stsCredentials.accessKeyId,
|
||||
stsCredentials.accessKeySecret,
|
||||
@@ -92,3 +84,5 @@ void StsAssumeRoleCredentialsProvider::loadCredentials()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
121
core/src/Url.cc
121
core/src/Url.cc
@@ -18,10 +18,9 @@
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
namespace AlibabaCloud {
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
#define INVALID_PORT -1
|
||||
}
|
||||
|
||||
@@ -33,18 +32,15 @@ Url::Url(const std::string & url) :
|
||||
path_(),
|
||||
port_(INVALID_PORT),
|
||||
query_(),
|
||||
fragment_()
|
||||
{
|
||||
if(!url.empty())
|
||||
fragment_() {
|
||||
if (!url.empty())
|
||||
fromString(url);
|
||||
}
|
||||
|
||||
Url::~Url()
|
||||
{
|
||||
Url::~Url() {
|
||||
}
|
||||
|
||||
bool Url::operator==(const Url &url) const
|
||||
{
|
||||
bool Url::operator==(const Url &url) const {
|
||||
return scheme_ == url.scheme_
|
||||
&& userName_ == url.userName_
|
||||
&& password_ == url.password_
|
||||
@@ -55,13 +51,11 @@ bool Url::operator==(const Url &url) const
|
||||
&& fragment_ == url.fragment_;
|
||||
}
|
||||
|
||||
bool Url::operator!=(const Url &url) const
|
||||
{
|
||||
bool Url::operator!=(const Url &url) const {
|
||||
return !(*this == url);
|
||||
}
|
||||
|
||||
std::string Url::authority() const
|
||||
{
|
||||
std::string Url::authority() const {
|
||||
if (!isValid())
|
||||
return std::string();
|
||||
|
||||
@@ -75,8 +69,7 @@ std::string Url::authority() const
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void Url::clear()
|
||||
{
|
||||
void Url::clear() {
|
||||
scheme_.clear();
|
||||
userName_.clear();
|
||||
password_.clear();
|
||||
@@ -87,13 +80,11 @@ void Url::clear()
|
||||
fragment_.clear();
|
||||
}
|
||||
|
||||
std::string Url::fragment() const
|
||||
{
|
||||
std::string Url::fragment() const {
|
||||
return fragment_;
|
||||
}
|
||||
|
||||
void Url::fromString(const std::string & url)
|
||||
{
|
||||
void Url::fromString(const std::string & url) {
|
||||
clear();
|
||||
if (url.empty())
|
||||
return;
|
||||
@@ -124,9 +115,9 @@ void Url::fromString(const std::string & url)
|
||||
if (pos != str.npos) {
|
||||
path = str.substr(pos);
|
||||
str.erase(pos);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
path = "/";
|
||||
}
|
||||
|
||||
authority = str;
|
||||
|
||||
@@ -137,23 +128,19 @@ void Url::fromString(const std::string & url)
|
||||
setFragment(fragment);
|
||||
}
|
||||
|
||||
bool Url::hasFragment() const
|
||||
{
|
||||
bool Url::hasFragment() const {
|
||||
return !fragment_.empty();
|
||||
}
|
||||
|
||||
bool Url::hasQuery() const
|
||||
{
|
||||
bool Url::hasQuery() const {
|
||||
return !query_.empty();
|
||||
}
|
||||
|
||||
std::string Url::host() const
|
||||
{
|
||||
std::string Url::host() const {
|
||||
return host_;
|
||||
}
|
||||
|
||||
bool Url::isEmpty() const
|
||||
{
|
||||
bool Url::isEmpty() const {
|
||||
return scheme_.empty()
|
||||
&& userName_.empty()
|
||||
&& password_.empty()
|
||||
@@ -164,8 +151,7 @@ bool Url::isEmpty() const
|
||||
&& fragment_.empty();
|
||||
}
|
||||
|
||||
bool Url::isValid() const
|
||||
{
|
||||
bool Url::isValid() const {
|
||||
if (isEmpty())
|
||||
return false;
|
||||
|
||||
@@ -178,33 +164,27 @@ bool Url::isValid() const
|
||||
return valid;
|
||||
}
|
||||
|
||||
int Url::port() const
|
||||
{
|
||||
int Url::port() const {
|
||||
return port_;
|
||||
}
|
||||
|
||||
std::string Url::password() const
|
||||
{
|
||||
std::string Url::password() const {
|
||||
return password_;
|
||||
}
|
||||
|
||||
std::string Url::path() const
|
||||
{
|
||||
std::string Url::path() const {
|
||||
return path_;
|
||||
}
|
||||
|
||||
std::string Url::query() const
|
||||
{
|
||||
std::string Url::query() const {
|
||||
return query_;
|
||||
}
|
||||
|
||||
std::string Url::scheme() const
|
||||
{
|
||||
std::string Url::scheme() const {
|
||||
return scheme_;
|
||||
}
|
||||
|
||||
void Url::setAuthority(const std::string & authority)
|
||||
{
|
||||
void Url::setAuthority(const std::string & authority) {
|
||||
if (authority.empty()) {
|
||||
setUserInfo("");
|
||||
setHost("");
|
||||
@@ -219,15 +199,14 @@ void Url::setAuthority(const std::string & authority)
|
||||
if (pos != authority.npos) {
|
||||
userinfo = authority.substr(0, pos);
|
||||
prevpos = pos + 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
pos = authority.find(':', prevpos);
|
||||
if (pos == authority.npos)
|
||||
if (pos == authority.npos) {
|
||||
host = authority.substr(prevpos);
|
||||
else {
|
||||
} else {
|
||||
host = authority.substr(prevpos, pos - prevpos);
|
||||
port = authority.substr(pos + 1);
|
||||
}
|
||||
@@ -237,14 +216,12 @@ void Url::setAuthority(const std::string & authority)
|
||||
setPort(!port.empty() ? atoi(port.c_str()): INVALID_PORT);
|
||||
}
|
||||
|
||||
void Url::setFragment(const std::string & fragment)
|
||||
{
|
||||
void Url::setFragment(const std::string & fragment) {
|
||||
fragment_ = fragment;
|
||||
}
|
||||
|
||||
void Url::setHost(const std::string & host)
|
||||
{
|
||||
if(host.empty()){
|
||||
void Url::setHost(const std::string & host) {
|
||||
if (host.empty()) {
|
||||
host_.clear();
|
||||
return;
|
||||
}
|
||||
@@ -252,29 +229,24 @@ void Url::setHost(const std::string & host)
|
||||
std::transform(host_.begin(), host_.end(), host_.begin(), ::tolower);
|
||||
}
|
||||
|
||||
void Url::setPassword(const std::string & password)
|
||||
{
|
||||
void Url::setPassword(const std::string & password) {
|
||||
password_ = password;
|
||||
}
|
||||
|
||||
void Url::setPath(const std::string & path)
|
||||
{
|
||||
void Url::setPath(const std::string & path) {
|
||||
path_ = path;
|
||||
}
|
||||
|
||||
void Url::setPort(int port)
|
||||
{
|
||||
void Url::setPort(int port) {
|
||||
port_ = port;
|
||||
}
|
||||
|
||||
void Url::setQuery(const std::string & query)
|
||||
{
|
||||
void Url::setQuery(const std::string & query) {
|
||||
query_ = query;
|
||||
}
|
||||
|
||||
void Url::setScheme(const std::string & scheme)
|
||||
{
|
||||
if(scheme.empty()){
|
||||
void Url::setScheme(const std::string & scheme) {
|
||||
if (scheme.empty()) {
|
||||
scheme_.clear();
|
||||
return;
|
||||
}
|
||||
@@ -282,8 +254,7 @@ void Url::setScheme(const std::string & scheme)
|
||||
std::transform(scheme_.begin(), scheme_.end(), scheme_.begin(), ::tolower);
|
||||
}
|
||||
|
||||
void Url::setUserInfo(const std::string & userInfo)
|
||||
{
|
||||
void Url::setUserInfo(const std::string & userInfo) {
|
||||
if (userInfo.empty()) {
|
||||
userName_.clear();
|
||||
password_.clear();
|
||||
@@ -291,21 +262,19 @@ void Url::setUserInfo(const std::string & userInfo)
|
||||
}
|
||||
|
||||
auto pos = userInfo.find(':');
|
||||
if (pos == userInfo.npos)
|
||||
if (pos == userInfo.npos) {
|
||||
userName_ = userInfo;
|
||||
else {
|
||||
} else {
|
||||
userName_ = userInfo.substr(0, pos);
|
||||
password_ = userInfo.substr(pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Url::setUserName(const std::string & userName)
|
||||
{
|
||||
void Url::setUserName(const std::string & userName) {
|
||||
userName_ = userName;
|
||||
}
|
||||
|
||||
std::string Url::toString() const
|
||||
{
|
||||
std::string Url::toString() const {
|
||||
if (!isValid())
|
||||
return std::string();
|
||||
|
||||
@@ -326,8 +295,7 @@ std::string Url::toString() const
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string Url::userInfo() const
|
||||
{
|
||||
std::string Url::userInfo() const {
|
||||
if (!isValid())
|
||||
return std::string();
|
||||
|
||||
@@ -338,7 +306,8 @@ std::string Url::userInfo() const
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string Url::userName() const
|
||||
{
|
||||
std::string Url::userName() const {
|
||||
return userName_;
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "Utils.h"
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <curl/curl.h>
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
@@ -25,16 +24,16 @@
|
||||
#include <openssl/md5.h>
|
||||
#include <uuid/uuid.h>
|
||||
#endif
|
||||
#include <curl/curl.h>
|
||||
|
||||
std::string AlibabaCloud::GenerateUuid()
|
||||
{
|
||||
std::string AlibabaCloud::GenerateUuid() {
|
||||
#ifdef _WIN32
|
||||
char *data;
|
||||
UUID uuidhandle;
|
||||
UuidCreate(&uuidhandle);
|
||||
UuidToString(&uuidhandle, (RPC_CSTR*)&data);
|
||||
UuidToString(&uuidhandle, reinterpret_cast<RPC_CSTR*>&data);
|
||||
std::string uuid(data);
|
||||
RpcStringFree((RPC_CSTR*)&data);
|
||||
RpcStringFree(reinterpret_cast<RPC_CSTR*>&data);
|
||||
return uuid;
|
||||
#else
|
||||
uuid_t uu;
|
||||
@@ -45,8 +44,7 @@ std::string AlibabaCloud::GenerateUuid()
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string AlibabaCloud::UrlEncode(const std::string & src)
|
||||
{
|
||||
std::string AlibabaCloud::UrlEncode(const std::string & src) {
|
||||
CURL *curl = curl_easy_init();
|
||||
char *output = curl_easy_escape(curl, src.c_str(), src.size());
|
||||
std::string result(output);
|
||||
@@ -54,8 +52,7 @@ std::string AlibabaCloud::UrlEncode(const std::string & src)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string AlibabaCloud::UrlDecode(const std::string & src)
|
||||
{
|
||||
std::string AlibabaCloud::UrlDecode(const std::string & src) {
|
||||
CURL *curl = curl_easy_init();
|
||||
int outlength = 0;
|
||||
char *output = curl_easy_unescape(curl, src.c_str(), src.size(), &outlength);
|
||||
@@ -64,8 +61,7 @@ std::string AlibabaCloud::UrlDecode(const std::string & src)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string AlibabaCloud::ComputeContentMD5(const char * data, size_t size)
|
||||
{
|
||||
std::string AlibabaCloud::ComputeContentMD5(const char * data, size_t size) {
|
||||
#ifdef _WIN32
|
||||
HCRYPTPROV hProv = 0;
|
||||
HCRYPTHASH hHash = 0;
|
||||
@@ -74,16 +70,18 @@ std::string AlibabaCloud::ComputeContentMD5(const char * data, size_t size)
|
||||
|
||||
CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash);
|
||||
CryptHashData(hHash, (BYTE*)(data), size, 0);
|
||||
CryptHashData(hHash, reinterpret_cast<BYTE*>(data), size, 0);
|
||||
CryptGetHashParam(hHash, HP_HASHVAL, pbHash, &dwDataLen, 0);
|
||||
|
||||
CryptDestroyHash(hHash);
|
||||
CryptReleaseContext(hProv, 0);
|
||||
|
||||
DWORD dlen = 0;
|
||||
CryptBinaryToString(pbHash, dwDataLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, NULL, &dlen);
|
||||
CryptBinaryToString(pbHash, dwDataLen,
|
||||
CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, NULL, &dlen);
|
||||
char* dest = new char[dlen];
|
||||
CryptBinaryToString(pbHash, dwDataLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
|
||||
CryptBinaryToString(pbHash,
|
||||
dwDataLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, dest, &dlen);
|
||||
|
||||
std::string ret = std::string(dest, dlen);
|
||||
delete dest;
|
||||
@@ -93,25 +91,23 @@ std::string AlibabaCloud::ComputeContentMD5(const char * data, size_t size)
|
||||
MD5(reinterpret_cast<const unsigned char*>(data), size, (unsigned char*)&md);
|
||||
|
||||
char encodedData[100];
|
||||
EVP_EncodeBlock(reinterpret_cast<unsigned char*>(encodedData), md, MD5_DIGEST_LENGTH);
|
||||
EVP_EncodeBlock(reinterpret_cast<unsigned char*>(encodedData),
|
||||
md, MD5_DIGEST_LENGTH);
|
||||
return encodedData;
|
||||
#endif
|
||||
}
|
||||
|
||||
void AlibabaCloud::StringReplace(std::string & src, const std::string & s1, const std::string & s2)
|
||||
{
|
||||
std::string::size_type pos =0;
|
||||
while ((pos = src.find(s1, pos)) != std::string::npos)
|
||||
{
|
||||
void AlibabaCloud::StringReplace(std::string & src,
|
||||
const std::string & s1, const std::string & s2) {
|
||||
std::string::size_type pos = 0;
|
||||
while ((pos = src.find(s1, pos)) != std::string::npos) {
|
||||
src.replace(pos, s1.length(), s2);
|
||||
pos += s2.length();
|
||||
}
|
||||
}
|
||||
|
||||
std::string AlibabaCloud::HttpMethodToString(HttpRequest::Method method)
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
std::string AlibabaCloud::HttpMethodToString(HttpRequest::Method method) {
|
||||
switch (method) {
|
||||
case HttpRequest::Method::Head:
|
||||
return "HEAD";
|
||||
break;
|
||||
@@ -143,14 +139,13 @@ std::string AlibabaCloud::HttpMethodToString(HttpRequest::Method method)
|
||||
}
|
||||
}
|
||||
|
||||
std::string AlibabaCloud::canonicalizedQuery(const std::map<std::string, std::string>& params)
|
||||
{
|
||||
std::string AlibabaCloud::canonicalizedQuery(const std::map<std::string,
|
||||
std::string>& params) {
|
||||
if (params.empty())
|
||||
return std::string();
|
||||
|
||||
std::stringstream ss;
|
||||
for (const auto &p : params)
|
||||
{
|
||||
for (const auto &p : params) {
|
||||
std::string key = UrlEncode(p.first);
|
||||
StringReplace(key, "+", "%20");
|
||||
StringReplace(key, "*", "%2A");
|
||||
@@ -164,11 +159,10 @@ std::string AlibabaCloud::canonicalizedQuery(const std::map<std::string, std::st
|
||||
return ss.str().substr(1);
|
||||
}
|
||||
|
||||
std::string AlibabaCloud::canonicalizedHeaders(const HttpMessage::HeaderCollection &headers)
|
||||
{
|
||||
std::string AlibabaCloud::canonicalizedHeaders(
|
||||
const HttpMessage::HeaderCollection &headers) {
|
||||
std::map <std::string, std::string> materials;
|
||||
for (const auto &p : headers)
|
||||
{
|
||||
for (const auto &p : headers) {
|
||||
std::string key = p.first;
|
||||
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||
if (key.find("x-acs-") != 0)
|
||||
|
||||
@@ -14,22 +14,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_UTILS_H_
|
||||
#define ALIBABACLOUD_CORE_UTILS_H_
|
||||
#ifndef CORE_SRC_UTILS_H_
|
||||
#define CORE_SRC_UTILS_H_
|
||||
|
||||
#include <string>
|
||||
#include <alibabacloud/core/HttpRequest.h>
|
||||
#include <alibabacloud/core/HttpMessage.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
std::string ComputeContentMD5(const char *data, size_t size);
|
||||
std::string GenerateUuid();
|
||||
std::string HttpMethodToString(HttpRequest::Method method);
|
||||
void StringReplace(std::string &src, const std::string &s1, const std::string &s2);
|
||||
std::string UrlEncode(const std::string &src);
|
||||
std::string UrlDecode(const std::string &src);
|
||||
std::string canonicalizedQuery(const std::map <std::string, std::string> ¶ms);
|
||||
std::string canonicalizedHeaders(const HttpMessage::HeaderCollection &headers);
|
||||
}
|
||||
#endif
|
||||
namespace AlibabaCloud {
|
||||
std::string ComputeContentMD5(const char *data, size_t size);
|
||||
std::string GenerateUuid();
|
||||
std::string HttpMethodToString(HttpRequest::Method method);
|
||||
void StringReplace(std::string &src,
|
||||
const std::string &s1, const std::string &s2);
|
||||
std::string UrlEncode(const std::string &src);
|
||||
std::string UrlDecode(const std::string &src);
|
||||
std::string canonicalizedQuery(const std::map <std::string,
|
||||
std::string> ¶ms);
|
||||
std::string canonicalizedHeaders(const HttpMessage::HeaderCollection &headers);
|
||||
} // namespace AlibabaCloud
|
||||
#endif // CORE_SRC_UTILS_H_
|
||||
|
||||
@@ -20,60 +20,67 @@
|
||||
using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Location;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
const std::string SERVICE_NAME = "Location";
|
||||
const std::string ENDPOINT = "location.aliyuncs.com";
|
||||
}
|
||||
|
||||
LocationClient::LocationClient(const Credentials &credentials, const ClientConfiguration &configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
|
||||
{
|
||||
LocationClient::LocationClient(const Credentials &credentials,
|
||||
const ClientConfiguration &configuration) :
|
||||
RpcServiceClient(SERVICE_NAME,
|
||||
std::make_shared<SimpleCredentialsProvider>(credentials), configuration) {
|
||||
}
|
||||
|
||||
LocationClient::LocationClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
|
||||
{
|
||||
LocationClient::LocationClient(
|
||||
const std::shared_ptr<CredentialsProvider>& 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<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
|
||||
{
|
||||
LocationClient::LocationClient(const std::string & accessKeyId,
|
||||
const std::string & accessKeySecret,
|
||||
const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(SERVICE_NAME,
|
||||
std::make_shared<SimpleCredentialsProvider>(accessKeyId,
|
||||
accessKeySecret), configuration) {
|
||||
}
|
||||
|
||||
LocationClient::LocationClient(const std::shared_ptr<Location::LocationClient>& locationClient):
|
||||
RpcServiceClient(SERVICE_NAME, locationClient->credentialsProvider(), locationClient->configuration())
|
||||
{
|
||||
LocationClient::LocationClient(
|
||||
const std::shared_ptr<Location::LocationClient>& locationClient):
|
||||
RpcServiceClient(SERVICE_NAME,
|
||||
locationClient->credentialsProvider(),
|
||||
locationClient->configuration()) {
|
||||
}
|
||||
|
||||
|
||||
LocationClient::~LocationClient()
|
||||
{}
|
||||
LocationClient::~LocationClient() {}
|
||||
|
||||
LocationClient::DescribeEndpointsOutcome LocationClient::describeEndpoints(const Model::DescribeEndpointsRequest &request) const
|
||||
{
|
||||
LocationClient::DescribeEndpointsOutcome LocationClient::describeEndpoints(
|
||||
const Model::DescribeEndpointsRequest &request) const {
|
||||
auto outcome = makeRequest(ENDPOINT, request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return DescribeEndpointsOutcome(Model::DescribeEndpointsResult(outcome.result()));
|
||||
return DescribeEndpointsOutcome(
|
||||
Model::DescribeEndpointsResult(outcome.result()));
|
||||
else
|
||||
return DescribeEndpointsOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void LocationClient::describeEndpointsAsync(const Model::DescribeEndpointsRequest& request, const DescribeEndpointsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
void LocationClient::describeEndpointsAsync(
|
||||
const Model::DescribeEndpointsRequest& request,
|
||||
const DescribeEndpointsAsyncHandler& handler,
|
||||
const std::shared_ptr<const AsyncCallerContext>& context) const {
|
||||
std::async(std::launch::async,
|
||||
[this, request, handler, context]()
|
||||
{
|
||||
[this, request, handler, context]() {
|
||||
handler(this, request, describeEndpoints(request), context);
|
||||
});
|
||||
}
|
||||
|
||||
LocationClient::DescribeEndpointsOutcomeCallable LocationClient::describeEndpointsCallable(const Model::DescribeEndpointsRequest &request) const
|
||||
{
|
||||
LocationClient::DescribeEndpointsOutcomeCallable
|
||||
LocationClient::describeEndpointsCallable(
|
||||
const Model::DescribeEndpointsRequest &request) const {
|
||||
auto task = std::make_shared<std::packaged_task<DescribeEndpointsOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
[this, request]() {
|
||||
return this->describeEndpoints(request);
|
||||
});
|
||||
|
||||
|
||||
@@ -19,10 +19,8 @@
|
||||
using namespace AlibabaCloud::Location;
|
||||
|
||||
LocationRequest::LocationRequest(const std::string & action) :
|
||||
RpcServiceRequest("location", "2015-06-12", action)
|
||||
{
|
||||
RpcServiceRequest("location", "2015-06-12", action) {
|
||||
}
|
||||
|
||||
LocationRequest::~LocationRequest()
|
||||
{
|
||||
LocationRequest::~LocationRequest() {
|
||||
}
|
||||
|
||||
@@ -26,32 +26,26 @@ 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
|
||||
{
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -21,21 +21,17 @@ using namespace AlibabaCloud::Location;
|
||||
using namespace AlibabaCloud::Location::Model;
|
||||
|
||||
DescribeEndpointsResult::DescribeEndpointsResult() :
|
||||
ServiceResult()
|
||||
{
|
||||
ServiceResult() {
|
||||
}
|
||||
|
||||
DescribeEndpointsResult::DescribeEndpointsResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
ServiceResult() {
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
DescribeEndpointsResult::~DescribeEndpointsResult()
|
||||
{}
|
||||
DescribeEndpointsResult::~DescribeEndpointsResult() {}
|
||||
|
||||
void DescribeEndpointsResult::parse(const std::string &payload)
|
||||
{
|
||||
void DescribeEndpointsResult::parse(const std::string &payload) {
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
@@ -44,8 +40,7 @@ void DescribeEndpointsResult::parse(const std::string &payload)
|
||||
|
||||
success_ = value["Success"].asBool();
|
||||
auto allEndpoints = value["Endpoints"]["Endpoint"];
|
||||
for (const auto &item : allEndpoints)
|
||||
{
|
||||
for (const auto &item : allEndpoints) {
|
||||
Endpoint region;
|
||||
region.endpoint = item["Endpoint"].asString();
|
||||
region.id = item["Id"].asString();
|
||||
@@ -53,30 +48,27 @@ void DescribeEndpointsResult::parse(const std::string &payload)
|
||||
region.serivceCode = item["SerivceCode"].asString();
|
||||
region.type = item["Type"].asString();
|
||||
auto allProtocols = item["Protocols"]["Protocols"];
|
||||
for (const auto &item : allProtocols)
|
||||
{
|
||||
for (const auto &item : allProtocols) {
|
||||
region.protocols.push_back(item.asString());
|
||||
}
|
||||
endpoints_.push_back(region);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<DescribeEndpointsResult::Endpoint> DescribeEndpointsResult::endpoints()const
|
||||
{
|
||||
std::vector<DescribeEndpointsResult::Endpoint>
|
||||
DescribeEndpointsResult::endpoints()const {
|
||||
return endpoints_;
|
||||
}
|
||||
|
||||
void DescribeEndpointsResult::setEndpoints(const std::vector<Endpoint> & endpoints)
|
||||
{
|
||||
void DescribeEndpointsResult::setEndpoints(
|
||||
const std::vector<Endpoint> & endpoints) {
|
||||
endpoints_ = endpoints;
|
||||
}
|
||||
|
||||
bool DescribeEndpointsResult::success()const
|
||||
{
|
||||
bool DescribeEndpointsResult::success()const {
|
||||
return success_;
|
||||
}
|
||||
|
||||
void DescribeEndpointsResult::setSuccess(const bool & success)
|
||||
{
|
||||
void DescribeEndpointsResult::setSuccess(const bool & success) {
|
||||
success_ = success;
|
||||
}
|
||||
|
||||
@@ -22,33 +22,36 @@ using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Sts;
|
||||
using namespace AlibabaCloud::Sts::Model;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
const std::string SERVICE_NAME = "Sts";
|
||||
const std::string ENDPOINT = "sts.aliyuncs.com";
|
||||
}
|
||||
|
||||
StsClient::StsClient(const Credentials &credentials, const ClientConfiguration &configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
|
||||
{
|
||||
StsClient::StsClient(const Credentials &credentials,
|
||||
const ClientConfiguration &configuration) :
|
||||
RpcServiceClient(SERVICE_NAME,
|
||||
std::make_shared<SimpleCredentialsProvider>(credentials), configuration) {
|
||||
}
|
||||
|
||||
StsClient::StsClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
|
||||
{
|
||||
StsClient::StsClient(
|
||||
const std::shared_ptr<CredentialsProvider>& credentialsProvider,
|
||||
const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) {
|
||||
}
|
||||
|
||||
StsClient::StsClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
|
||||
{
|
||||
StsClient::StsClient(const std::string & accessKeyId,
|
||||
const std::string & accessKeySecret,
|
||||
const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(SERVICE_NAME,
|
||||
std::make_shared<SimpleCredentialsProvider>(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())
|
||||
@@ -57,21 +60,20 @@ StsClient::AssumeRoleOutcome StsClient::assumeRole(const Model::AssumeRoleReques
|
||||
return AssumeRoleOutcome(Error(outcome.error()));
|
||||
}
|
||||
|
||||
void StsClient::assumeRoleAsync(const Model::AssumeRoleRequest & request, const AssumeRoleAsyncHandler & handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
void StsClient::assumeRoleAsync(const Model::AssumeRoleRequest & request,
|
||||
const AssumeRoleAsyncHandler & handler,
|
||||
const std::shared_ptr<const AsyncCallerContext>& context) const {
|
||||
auto fn = [this, request, handler, context]() {
|
||||
handler(this, request, assumeRole(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
StsClient::AssumeRoleOutcomeCallable StsClient::assumeRoleCallable(const Model::AssumeRoleRequest & request) const
|
||||
{
|
||||
StsClient::AssumeRoleOutcomeCallable StsClient::assumeRoleCallable(
|
||||
const Model::AssumeRoleRequest & request) const {
|
||||
auto task = std::make_shared<std::packaged_task<AssumeRoleOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
[this, request]() {
|
||||
return this->assumeRole(request);
|
||||
});
|
||||
|
||||
@@ -79,8 +81,8 @@ StsClient::AssumeRoleOutcomeCallable StsClient::assumeRoleCallable(const Model::
|
||||
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())
|
||||
@@ -89,21 +91,21 @@ StsClient::GetCallerIdentityOutcome StsClient::getCallerIdentity(const GetCaller
|
||||
return GetCallerIdentityOutcome(Error(outcome.error()));
|
||||
}
|
||||
|
||||
void StsClient::getCallerIdentityAsync(const GetCallerIdentityRequest& request, const GetCallerIdentityAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
void StsClient::getCallerIdentityAsync(const GetCallerIdentityRequest& request,
|
||||
const GetCallerIdentityAsyncHandler& handler,
|
||||
const std::shared_ptr<const AsyncCallerContext>& context) const {
|
||||
auto fn = [this, request, handler, context]() {
|
||||
handler(this, request, getCallerIdentity(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
StsClient::GetCallerIdentityOutcomeCallable StsClient::getCallerIdentityCallable(const GetCallerIdentityRequest &request) const
|
||||
{
|
||||
StsClient::GetCallerIdentityOutcomeCallable
|
||||
StsClient::getCallerIdentityCallable(
|
||||
const GetCallerIdentityRequest &request) const {
|
||||
auto task = std::make_shared<std::packaged_task<GetCallerIdentityOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
[this, request]() {
|
||||
return this->getCallerIdentity(request);
|
||||
});
|
||||
|
||||
|
||||
@@ -20,10 +20,8 @@ using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Sts;
|
||||
|
||||
StsRequest::StsRequest(const std::string & action) :
|
||||
RpcServiceRequest("sts", "2015-04-01", action)
|
||||
{
|
||||
RpcServiceRequest("sts", "2015-04-01", action) {
|
||||
}
|
||||
|
||||
StsRequest::~StsRequest()
|
||||
{
|
||||
StsRequest::~StsRequest() {
|
||||
}
|
||||
|
||||
@@ -16,58 +16,49 @@
|
||||
|
||||
#include <alibabacloud/core/sts/model/AssumeRoleRequest.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
// using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Sts;
|
||||
using namespace AlibabaCloud::Sts::Model;
|
||||
|
||||
AssumeRoleRequest::AssumeRoleRequest() :
|
||||
StsRequest("AssumeRole")
|
||||
{
|
||||
StsRequest("AssumeRole") {
|
||||
setRoleArn("");
|
||||
setRoleSessionName("");
|
||||
setDurationSeconds(3600);
|
||||
}
|
||||
|
||||
AssumeRoleRequest::~AssumeRoleRequest()
|
||||
{
|
||||
AssumeRoleRequest::~AssumeRoleRequest() {
|
||||
}
|
||||
|
||||
int AssumeRoleRequest::durationSeconds() const
|
||||
{
|
||||
int AssumeRoleRequest::durationSeconds() const {
|
||||
return std::stoi(parameter("DurationSeconds"));
|
||||
}
|
||||
|
||||
std::string AssumeRoleRequest::policy() const
|
||||
{
|
||||
std::string AssumeRoleRequest::policy() const {
|
||||
return parameter("Policy");
|
||||
}
|
||||
|
||||
std::string AssumeRoleRequest::roleArn() const
|
||||
{
|
||||
std::string AssumeRoleRequest::roleArn() const {
|
||||
return parameter("RoleArn");
|
||||
}
|
||||
|
||||
std::string AssumeRoleRequest::roleSessionName() const
|
||||
{
|
||||
std::string AssumeRoleRequest::roleSessionName() const {
|
||||
return parameter("RoleSessionName");
|
||||
}
|
||||
|
||||
void AssumeRoleRequest::setDurationSeconds(int durationSeconds)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -23,34 +23,28 @@ using namespace AlibabaCloud::Sts::Model;
|
||||
AssumeRoleResult::AssumeRoleResult() :
|
||||
ServiceResult(),
|
||||
assumedRoleUser_(),
|
||||
credentials_()
|
||||
{
|
||||
credentials_() {
|
||||
}
|
||||
|
||||
AssumeRoleResult::AssumeRoleResult(const std::string & payload) :
|
||||
ServiceResult(),
|
||||
assumedRoleUser_(),
|
||||
credentials_()
|
||||
{
|
||||
credentials_() {
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
AssumeRoleResult::~AssumeRoleResult()
|
||||
{
|
||||
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);
|
||||
@@ -58,7 +52,8 @@ void AssumeRoleResult::parse(const std::string & payload)
|
||||
setRequestId(value["RequestId"].asString());
|
||||
|
||||
auto assumedRoleUserNode = value["AssumedRoleUser"];
|
||||
assumedRoleUser_.assumedRoleId = assumedRoleUserNode["AssumedRoleId"].asString();
|
||||
assumedRoleUser_.assumedRoleId =
|
||||
assumedRoleUserNode["AssumedRoleId"].asString();
|
||||
assumedRoleUser_.arn = assumedRoleUserNode["Arn"].asString();
|
||||
|
||||
auto credentialsNode = value["Credentials"];
|
||||
|
||||
@@ -21,10 +21,8 @@ using namespace AlibabaCloud::Sts;
|
||||
using namespace AlibabaCloud::Sts::Model;
|
||||
|
||||
GetCallerIdentityRequest::GetCallerIdentityRequest() :
|
||||
StsRequest("GetCallerIdentity")
|
||||
{
|
||||
StsRequest("GetCallerIdentity") {
|
||||
}
|
||||
|
||||
GetCallerIdentityRequest::~GetCallerIdentityRequest()
|
||||
{
|
||||
GetCallerIdentityRequest::~GetCallerIdentityRequest() {
|
||||
}
|
||||
|
||||
@@ -25,40 +25,33 @@ GetCallerIdentityResult::GetCallerIdentityResult() :
|
||||
ServiceResult(),
|
||||
accountId_(),
|
||||
arn_(),
|
||||
userId_()
|
||||
{
|
||||
userId_() {
|
||||
}
|
||||
|
||||
GetCallerIdentityResult::GetCallerIdentityResult(const std::string & payload) :
|
||||
ServiceResult(),
|
||||
accountId_(),
|
||||
arn_(),
|
||||
userId_()
|
||||
{
|
||||
userId_() {
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
GetCallerIdentityResult::~GetCallerIdentityResult()
|
||||
{
|
||||
GetCallerIdentityResult::~GetCallerIdentityResult() {
|
||||
}
|
||||
|
||||
std::string GetCallerIdentityResult::accountId()
|
||||
{
|
||||
std::string GetCallerIdentityResult::accountId() {
|
||||
return accountId_;
|
||||
}
|
||||
|
||||
std::string GetCallerIdentityResult::arn() const
|
||||
{
|
||||
std::string GetCallerIdentityResult::arn() const {
|
||||
return arn_;
|
||||
}
|
||||
|
||||
std::string GetCallerIdentityResult::userId() const
|
||||
{
|
||||
std::string GetCallerIdentityResult::userId() const {
|
||||
return userId_;
|
||||
}
|
||||
|
||||
void GetCallerIdentityResult::parse(const std::string & payload)
|
||||
{
|
||||
void GetCallerIdentityResult::parse(const std::string & payload) {
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
|
||||
Reference in New Issue
Block a user