1
core/include/alibabacloud/core/.gitignore
vendored
Normal file
1
core/include/alibabacloud/core/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Config.h
|
||||
29
core/include/alibabacloud/core/AlibabaCloud.h
Normal file
29
core/include/alibabacloud/core/AlibabaCloud.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ALIBABACLOUD_H_
|
||||
#define ALIBABACLOUD_CORE_ALIBABACLOUD_H_
|
||||
|
||||
#include "CoreExport.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
ALIBABACLOUD_CORE_EXPORT void InitializeSdk();
|
||||
ALIBABACLOUD_CORE_EXPORT bool IsSdkInitialized();
|
||||
ALIBABACLOUD_CORE_EXPORT void ShutdownSdk();
|
||||
}
|
||||
|
||||
#endif
|
||||
38
core/include/alibabacloud/core/AsyncCallerContext.h
Normal file
38
core/include/alibabacloud/core/AsyncCallerContext.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ASYNCCALLERCONTEXT_H_
|
||||
#define 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();
|
||||
|
||||
std::string uuid()const;
|
||||
void setUuid(const std::string &uuid);
|
||||
private:
|
||||
std::string uuid_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
49
core/include/alibabacloud/core/ClientConfiguration.h
Normal file
49
core/include/alibabacloud/core/ClientConfiguration.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_
|
||||
#define ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "CredentialsProvider.h"
|
||||
#include "CoreExport.h"
|
||||
#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();
|
||||
|
||||
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_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_CLIENTCONFIGURATION_H_
|
||||
65
core/include/alibabacloud/core/CommonClient.h
Normal file
65
core/include/alibabacloud/core/CommonClient.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_COMMONCLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_COMMONCLIENT_H_
|
||||
|
||||
#include <future>
|
||||
#include "ClientConfiguration.h"
|
||||
#include "CoreExport.h"
|
||||
#include "CoreClient.h"
|
||||
#include "CredentialsProvider.h"
|
||||
#include "EndpointProvider.h"
|
||||
#include "CommonRequest.h"
|
||||
#include "CommonResponse.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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
virtual EndpointOutcome endpoint() const override;
|
||||
JsonOutcome makeRequest(const std::string &endpoint, const CommonRequest &msg, HttpRequest::Method method = HttpRequest::Method::Get)const;
|
||||
|
||||
private:
|
||||
std::string canonicalizedQuery(const std::map <std::string, std::string> ¶ms)const;
|
||||
std::string canonicalizedHeaders(const HttpMessage::HeaderCollection &headers)const;
|
||||
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
std::shared_ptr<EndpointProvider> endpointProvider_;
|
||||
std::shared_ptr<Signer> signer_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_COMMONCLIENT_H_
|
||||
59
core/include/alibabacloud/core/CommonRequest.h
Normal file
59
core/include/alibabacloud/core/CommonRequest.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_COMMONREQUEST_H_
|
||||
#define 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:
|
||||
CommonRequest();
|
||||
~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 setUriPattern(const std::string &uriPattern);
|
||||
using ServiceRequest::setVersion;
|
||||
std::string uriPattern()const;
|
||||
protected:
|
||||
using ServiceRequest::product;
|
||||
|
||||
private:
|
||||
std::string domain_;
|
||||
std::string uriPattern_;
|
||||
ParameterCollection queryParams_;
|
||||
ParameterCollection headerParams_;
|
||||
HttpRequest::Method httpMethod_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_COMMONREQUEST_H_
|
||||
38
core/include/alibabacloud/core/CommonResponse.h
Normal file
38
core/include/alibabacloud/core/CommonResponse.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_COMMONRESPONSE_H_
|
||||
#define 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();
|
||||
|
||||
std::string payload()const;
|
||||
private:
|
||||
std::string payload_;
|
||||
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_COMMONRESPONSE_H_
|
||||
55
core/include/alibabacloud/core/CoreClient.h
Normal file
55
core/include/alibabacloud/core/CoreClient.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_CORECLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_CORECLIENT_H_
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include "ClientConfiguration.h"
|
||||
#include "CoreExport.h"
|
||||
#include "HttpClient.h"
|
||||
#include "HttpResponse.h"
|
||||
#include "HttpRequest.h"
|
||||
#include "Outcome.h"
|
||||
#include "ServiceRequest.h"
|
||||
#include "Runnable.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT CoreClient
|
||||
{
|
||||
public:
|
||||
CoreClient(const ClientConfiguration &configuration);
|
||||
virtual ~CoreClient();
|
||||
|
||||
ClientConfiguration configuration()const;
|
||||
protected:
|
||||
typedef Outcome<Error, std::string> EndpointOutcome;
|
||||
|
||||
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;
|
||||
virtual EndpointOutcome endpoint()const = 0;
|
||||
private:
|
||||
ClientConfiguration configuration_;
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
HttpClient *httpClient_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
32
core/include/alibabacloud/core/CoreExport.h
Normal file
32
core/include/alibabacloud/core/CoreExport.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_COREEXPORT_H_
|
||||
#define ALIBABACLOUD_CORE_COREEXPORT_H_
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
#if defined(ALIBABACLOUD_SHARED)
|
||||
# if defined(ALIBABACLOUD_CORE_LIBRARY)
|
||||
# define ALIBABACLOUD_CORE_EXPORT ALIBABACLOUD_DECL_EXPORT
|
||||
# else
|
||||
# define ALIBABACLOUD_CORE_EXPORT ALIBABACLOUD_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define ALIBABACLOUD_CORE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_COREEXPORT_H_
|
||||
47
core/include/alibabacloud/core/Credentials.h
Normal file
47
core/include/alibabacloud/core/Credentials.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_CREDENTIAL_H_
|
||||
#define ALIBABACLOUD_CORE_CREDENTIAL_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();
|
||||
|
||||
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_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_CREDENTIAL_H_
|
||||
36
core/include/alibabacloud/core/CredentialsProvider.h
Normal file
36
core/include/alibabacloud/core/CredentialsProvider.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_CREDENTIALSPROVIDER_H_
|
||||
#define ALIBABACLOUD_CORE_CREDENTIALSPROVIDER_H_
|
||||
|
||||
#include "CoreExport.h"
|
||||
#include "Credentials.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT CredentialsProvider
|
||||
{
|
||||
public:
|
||||
CredentialsProvider() = default;
|
||||
virtual ~CredentialsProvider() = default;
|
||||
|
||||
virtual Credentials getCredentials() = 0;
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ECSINSTANCEPROFILECONFIGLOADER_H_
|
||||
#define ALIBABACLOUD_CORE_ECSINSTANCEPROFILECONFIGLOADER_H_
|
||||
|
||||
#include <memory>
|
||||
#include "InstanceProfileConfigLoader.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class EcsMetadataClient;
|
||||
class EcsInstanceProfileConfigLoader : public InstanceProfileConfigLoader
|
||||
{
|
||||
public:
|
||||
EcsInstanceProfileConfigLoader();
|
||||
EcsInstanceProfileConfigLoader(const std::shared_ptr<EcsMetadataClient>& metadataClient);
|
||||
~EcsInstanceProfileConfigLoader();
|
||||
|
||||
protected:
|
||||
virtual bool loadInternal() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<EcsMetadataClient> metadataClient_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_ECSINSTANCEPROFILECONFIGLOADER_H_
|
||||
51
core/include/alibabacloud/core/EndpointProvider.h
Normal file
51
core/include/alibabacloud/core/EndpointProvider.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_
|
||||
#define ALIBABACLOUD_CORE_ENDPOINTPROVIDER_H_
|
||||
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <alibabacloud/core/location/LocationClient.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT EndpointProvider
|
||||
{
|
||||
public:
|
||||
EndpointProvider(const std::shared_ptr<Location::LocationClient>& locationClient,
|
||||
const std::string regionId,
|
||||
const std::string serviceCode,
|
||||
int durationSeconds = 3600);
|
||||
~EndpointProvider();
|
||||
|
||||
std::string getEndpoint();
|
||||
|
||||
private:
|
||||
void loadEndpoint();
|
||||
bool checkExpiry()const;
|
||||
|
||||
std::mutex cachedMutex_;
|
||||
std::string cachedEndpoint_;
|
||||
std::shared_ptr<Location::LocationClient> locationClient_;
|
||||
int durationSeconds_;
|
||||
std::chrono::system_clock::time_point expiry_;
|
||||
std::string regionId_;
|
||||
std::string serviceCode_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
48
core/include/alibabacloud/core/Error.h
Normal file
48
core/include/alibabacloud/core/Error.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ERROR_H_
|
||||
#define 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;
|
||||
|
||||
std::string errorCode()const;
|
||||
std::string errorMessage() const;
|
||||
std::string host() const;
|
||||
std::string requestId() 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);
|
||||
private:
|
||||
std::string errorCode_;
|
||||
std::string message_;
|
||||
std::string host_;
|
||||
std::string requestId_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_ERROR_H_
|
||||
41
core/include/alibabacloud/core/Global.h
Normal file
41
core/include/alibabacloud/core/Global.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_GLOBAL_H_
|
||||
#define ALIBABACLOUD_CORE_GLOBAL_H_
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# ifdef _MSC_VER
|
||||
# pragma warning(disable : 4251)
|
||||
# endif // _MSC_VER
|
||||
# define ALIBABACLOUD_DECL_EXPORT __declspec(dllexport)
|
||||
# define ALIBABACLOUD_DECL_IMPORT __declspec(dllimport)
|
||||
#elif defined(__linux__)
|
||||
# define ALIBABACLOUD_DECL_EXPORT __attribute__((visibility("default")))
|
||||
# define ALIBABACLOUD_DECL_IMPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#if !defined(ALIBABACLOUD_DECL_EXPORT)
|
||||
# define ALIBABACLOUD_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
#if !defined(ALIBABACLOUD_DECL_IMPORT)
|
||||
# define ALIBABACLOUD_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_GLOBAL_H_
|
||||
34
core/include/alibabacloud/core/HmacSha1Signer.h
Normal file
34
core/include/alibabacloud/core/HmacSha1Signer.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_
|
||||
#define ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_
|
||||
|
||||
#include "Signer.h"
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_HMACSHA1SIGNER_H_
|
||||
43
core/include/alibabacloud/core/HttpClient.h
Normal file
43
core/include/alibabacloud/core/HttpClient.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HTTPCLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_HTTPCLIENT_H_
|
||||
|
||||
#include <alibabacloud/core/HttpRequest.h>
|
||||
#include <alibabacloud/core/HttpResponse.h>
|
||||
#include <alibabacloud/core/NetworkProxy.h>
|
||||
#include <alibabacloud/core/Outcome.h>
|
||||
#include <alibabacloud/core/Error.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class HttpClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, HttpResponse> HttpResponseOutcome;
|
||||
|
||||
HttpClient();
|
||||
virtual ~HttpClient();
|
||||
|
||||
virtual HttpResponseOutcome makeRequest(const HttpRequest &request) = 0;
|
||||
NetworkProxy proxy()const;
|
||||
void setProxy(const NetworkProxy &proxy);
|
||||
private:
|
||||
NetworkProxy proxy_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
82
core/include/alibabacloud/core/HttpMessage.h
Normal file
82
core/include/alibabacloud/core/HttpMessage.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HTTPMESSAGE_H_
|
||||
#define 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_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_HTTPMESSAGE_H_
|
||||
53
core/include/alibabacloud/core/HttpRequest.h
Normal file
53
core/include/alibabacloud/core/HttpRequest.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HTTPREQUEST_H_
|
||||
#define 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_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
43
core/include/alibabacloud/core/HttpResponse.h
Normal file
43
core/include/alibabacloud/core/HttpResponse.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_HTTPRESPONSE_H_
|
||||
#define 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();
|
||||
|
||||
HttpRequest request()const;
|
||||
void setStatusCode(int code);
|
||||
int statusCode()const;
|
||||
private:
|
||||
int statusCode_;
|
||||
HttpRequest request_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_HTTPRESPONSE_H_
|
||||
47
core/include/alibabacloud/core/InstanceProfileConfigLoader.h
Normal file
47
core/include/alibabacloud/core/InstanceProfileConfigLoader.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_INSTANCEPROFILECONFIGLOADER_H_
|
||||
#define ALIBABACLOUD_CORE_INSTANCEPROFILECONFIGLOADER_H_
|
||||
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "Profile.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class InstanceProfileConfigLoader
|
||||
{
|
||||
public:
|
||||
InstanceProfileConfigLoader();
|
||||
virtual ~InstanceProfileConfigLoader();
|
||||
|
||||
bool load();
|
||||
bool persistProfiles(const std::map<std::string, Profile>& profiles);
|
||||
|
||||
std::map<std::string, Profile> allProfiles() const;
|
||||
std::chrono::system_clock::time_point lastLoadTime() const;
|
||||
|
||||
protected:
|
||||
virtual bool loadInternal() = 0;
|
||||
virtual bool persistInternal(const std::map<std::string, Profile>&);
|
||||
|
||||
std::map<std::string, Profile> profiles_;
|
||||
std::chrono::system_clock::time_point lastLoadTime_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_INSTANCEPROFILECONFIGLOADER_H_
|
||||
34
core/include/alibabacloud/core/InstanceProfileCredentials.h
Normal file
34
core/include/alibabacloud/core/InstanceProfileCredentials.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_
|
||||
#define ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_
|
||||
|
||||
#include "BasicSessionCredentials.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class InstanceProfileCredentials : public BasicSessionCredentials
|
||||
{
|
||||
public:
|
||||
InstanceProfileCredentials();
|
||||
~InstanceProfileCredentials();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALS_H_
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_
|
||||
#define ALIBABACLOUD_CORE_INSTANCEPROFILECREDENTIALSPROVIDER_H_
|
||||
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include "CredentialsProvider.h"
|
||||
#include "Credentials.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class EcsInstanceProfileConfigLoader;
|
||||
class InstanceProfileConfigLoader;
|
||||
class ALIBABACLOUD_CORE_EXPORT InstanceProfileCredentialsProvider : public CredentialsProvider
|
||||
{
|
||||
public:
|
||||
InstanceProfileCredentialsProvider(size_t refreshRateMs = (1000 * 60 * 10));
|
||||
InstanceProfileCredentialsProvider(const std::shared_ptr<EcsInstanceProfileConfigLoader>&, size_t refreshRateMs = (1000 * 60 * 10));
|
||||
|
||||
virtual Credentials getCredentials() override;
|
||||
private:
|
||||
void refreshIfExpired();
|
||||
virtual bool isTimeToRefresh(long reloadFrequency);
|
||||
|
||||
std::chrono::system_clock::time_point lastLoaded_;
|
||||
std::shared_ptr<InstanceProfileConfigLoader> metadataConfigLoader_;
|
||||
size_t loadFrequencyMs_;
|
||||
mutable std::mutex m_reloadMutex;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
59
core/include/alibabacloud/core/NetworkProxy.h
Normal file
59
core/include/alibabacloud/core/NetworkProxy.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_NETWORKPROXY_H_
|
||||
#define 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_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_NETWORKPROXY_H_
|
||||
72
core/include/alibabacloud/core/Outcome.h
Normal file
72
core/include/alibabacloud/core/Outcome.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_OUTCOME_H_
|
||||
#define 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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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_
|
||||
52
core/include/alibabacloud/core/Profile.h
Normal file
52
core/include/alibabacloud/core/Profile.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_PROFILE_H_
|
||||
#define ALIBABACLOUD_CORE_PROFILE_H_
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <alibabacloud/core/Credentials.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class Profile
|
||||
{
|
||||
public:
|
||||
std::string name() const;
|
||||
void setName(const std::string& value);
|
||||
Credentials credentials() const;
|
||||
void setCredentials(const Credentials& value);
|
||||
std::string region() const;
|
||||
void setRegion(const std::string& value);
|
||||
std::string roleArn() const;
|
||||
void setRoleArn(const std::string& value);
|
||||
std::string sourceProfile() const;
|
||||
void setSourceProfile(const std::string& value);
|
||||
void setAllKeyValPairs(const std::map<std::string, std::string>& map);
|
||||
std::string value(const std::string& key);
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
std::string region_;
|
||||
Credentials credentials_;
|
||||
std::string roleArn_;
|
||||
std::string sourceProfile_;
|
||||
std::map<std::string, std::string> allKeyValPairs_;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_PROFILE_H_
|
||||
54
core/include/alibabacloud/core/RoaServiceClient.h
Normal file
54
core/include/alibabacloud/core/RoaServiceClient.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ROASERVICECLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_ROASERVICECLIENT_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "CoreClient.h"
|
||||
#include "CredentialsProvider.h"
|
||||
#include "HmacSha1Signer.h"
|
||||
#include "HttpRequest.h"
|
||||
#include "RoaServiceRequest.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class RoaErrorMarshaller;
|
||||
class ALIBABACLOUD_CORE_EXPORT RoaServiceClient : public CoreClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, std::string> JsonOutcome;
|
||||
|
||||
RoaServiceClient(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::string canonicalizedHeaders(const HttpMessage::HeaderCollection &headers)const;
|
||||
std::string canonicalizedResource(const std::string &path, std::map <std::string, std::string> ¶ms)const;
|
||||
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
std::shared_ptr<Signer> signer_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_ROASERVICECLIENT_H_
|
||||
32
core/include/alibabacloud/core/RoaServiceRequest.h
Normal file
32
core/include/alibabacloud/core/RoaServiceRequest.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_
|
||||
|
||||
#include "ServiceRequest.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT RoaServiceRequest : public ServiceRequest
|
||||
{
|
||||
public:
|
||||
RoaServiceRequest(const std::string &product, const std::string &version);
|
||||
virtual ~RoaServiceRequest();
|
||||
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_ROASERVICEREQUEST_H_
|
||||
55
core/include/alibabacloud/core/RpcServiceClient.h
Normal file
55
core/include/alibabacloud/core/RpcServiceClient.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "CoreClient.h"
|
||||
#include "CredentialsProvider.h"
|
||||
#include "HmacSha1Signer.h"
|
||||
#include "HttpRequest.h"
|
||||
#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;
|
||||
|
||||
RpcServiceClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider,
|
||||
const ClientConfiguration &configuration,
|
||||
const std::shared_ptr<Signer> &signer = std::make_shared<HmacSha1Signer>());
|
||||
virtual ~RpcServiceClient();
|
||||
|
||||
protected:
|
||||
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::string canonicalizedQuery(const std::map <std::string, std::string> ¶ms)const;
|
||||
|
||||
std::shared_ptr<CredentialsProvider> credentialsProvider_;
|
||||
std::shared_ptr<Signer> signer_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_RPCSERVICECLIENT_H_
|
||||
36
core/include/alibabacloud/core/RpcServiceRequest.h
Normal file
36
core/include/alibabacloud/core/RpcServiceRequest.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_
|
||||
|
||||
#include "ServiceRequest.h"
|
||||
|
||||
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;
|
||||
protected:
|
||||
void setActionName(const std::string &name);
|
||||
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_RPCSERVICEREQUEST_H_
|
||||
35
core/include/alibabacloud/core/Runnable.h
Normal file
35
core/include/alibabacloud/core/Runnable.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_RUNNABLE_H_
|
||||
#define 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;
|
||||
|
||||
private:
|
||||
std::function<void()> f_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_RUNNABLE_H_
|
||||
68
core/include/alibabacloud/core/ServiceRequest.h
Normal file
68
core/include/alibabacloud/core/ServiceRequest.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_SERVICEREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_SERVICEREQUEST_H_
|
||||
|
||||
#include <map>
|
||||
#include "CoreExport.h"
|
||||
#include "Url.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT ServiceRequest
|
||||
{
|
||||
public:
|
||||
typedef std::string ParameterNameType;
|
||||
typedef std::string ParameterValueType;
|
||||
typedef std::map<ParameterNameType, ParameterValueType> ParameterCollection;
|
||||
|
||||
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;
|
||||
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);
|
||||
|
||||
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);
|
||||
private:
|
||||
char *content_;
|
||||
size_t contentSize_;
|
||||
ParameterCollection params_;
|
||||
std::string product_;
|
||||
std::string resourcePath_;
|
||||
std::string version_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_SERVICEREQUEST_H_
|
||||
40
core/include/alibabacloud/core/ServiceResult.h
Normal file
40
core/include/alibabacloud/core/ServiceResult.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_SERVICERESULT_H_
|
||||
#define ALIBABACLOUD_CORE_SERVICERESULT_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
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_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_SERVICERESULT_H_
|
||||
46
core/include/alibabacloud/core/Signer.h
Normal file
46
core/include/alibabacloud/core/Signer.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_SIGNER_H_
|
||||
#define 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_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_SIGNER_H_
|
||||
37
core/include/alibabacloud/core/SimpleCredentialsProvider.h
Normal file
37
core/include/alibabacloud/core/SimpleCredentialsProvider.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_
|
||||
#define ALIBABACLOUD_CORE_SIMPLECREDENTIALSPROVIDER_H_
|
||||
|
||||
#include "CredentialsProvider.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT SimpleCredentialsProvider : public CredentialsProvider
|
||||
{
|
||||
public:
|
||||
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_
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_STS_STSASSUMEROLECREDENTIALSPROVIDER_H_
|
||||
#define ALIBABACLOUD_STS_STSASSUMEROLECREDENTIALSPROVIDER_H_
|
||||
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <alibabacloud/core/CredentialsProvider.h>
|
||||
#include <alibabacloud/core/sts/StsClient.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT StsAssumeRoleCredentialsProvider : public CredentialsProvider
|
||||
{
|
||||
public:
|
||||
StsAssumeRoleCredentialsProvider(const std::shared_ptr<Sts::StsClient>& stsClient,
|
||||
const std::string &roleArn,
|
||||
const std::string &roleSessionName,
|
||||
const std::string &policy = "",
|
||||
int durationSeconds = 3600);
|
||||
~StsAssumeRoleCredentialsProvider();
|
||||
|
||||
virtual Credentials getCredentials() override;
|
||||
private:
|
||||
void loadCredentials();
|
||||
bool checkExpiry()const;
|
||||
|
||||
std::mutex cachedMutex_;
|
||||
Credentials cachedCredentials_;
|
||||
std::shared_ptr<Sts::StsClient> stsClient_;
|
||||
int durationSeconds_;
|
||||
std::chrono::system_clock::time_point expiry_;
|
||||
std::string policy_;
|
||||
std::string roleArn_;
|
||||
std::string roleSessionName_;
|
||||
};
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_STSASSUMEROLECREDENTIALSPROVIDER_H_
|
||||
75
core/include/alibabacloud/core/Url.h
Normal file
75
core/include/alibabacloud/core/Url.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_URL_H_
|
||||
#define ALIBABACLOUD_CORE_URL_H_
|
||||
|
||||
#include <string>
|
||||
#include "CoreExport.h"
|
||||
|
||||
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_
|
||||
51
core/include/alibabacloud/core/location/LocationClient.h
Normal file
51
core/include/alibabacloud/core/location/LocationClient.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_
|
||||
|
||||
#include <future>
|
||||
#include <alibabacloud/core/AsyncCallerContext.h>
|
||||
#include <alibabacloud/core/RpcServiceClient.h>
|
||||
#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();
|
||||
|
||||
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;
|
||||
private:
|
||||
virtual EndpointOutcome endpoint()const override;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_LOCATION_LOCATIONCLIENT_H_
|
||||
38
core/include/alibabacloud/core/location/LocationRequest.h
Normal file
38
core/include/alibabacloud/core/location/LocationRequest.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_
|
||||
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Location
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT LocationRequest : public RpcServiceRequest
|
||||
{
|
||||
public:
|
||||
explicit LocationRequest(const std::string & action);
|
||||
virtual ~LocationRequest();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_LOCATION_LOCATIONREQUEST_H_
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <alibabacloud/core/location/LocationRequest.h>
|
||||
|
||||
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_
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_
|
||||
#define ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_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;
|
||||
};
|
||||
|
||||
DescribeEndpointsResult();
|
||||
explicit DescribeEndpointsResult(const std::string &payload);
|
||||
~DescribeEndpointsResult();
|
||||
|
||||
std::vector<Endpoint> endpoints()const;
|
||||
void setEndpoints(const std::vector<Endpoint> &endpoints);
|
||||
|
||||
bool success()const;
|
||||
void setSuccess(const bool &success);
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
std::vector<Endpoint> endpoints_;
|
||||
bool success_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_LOCATION_MODEL_DESCRIBEENDPOINTSRESULT_H_
|
||||
60
core/include/alibabacloud/core/sts/StsClient.h
Normal file
60
core/include/alibabacloud/core/sts/StsClient.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_STS_STSCLIENT_H_
|
||||
#define ALIBABACLOUD_CORE_STS_STSCLIENT_H_
|
||||
|
||||
#include <future>
|
||||
#include <alibabacloud/core/AsyncCallerContext.h>
|
||||
#include <alibabacloud/core/RpcServiceClient.h>
|
||||
#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;
|
||||
|
||||
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();
|
||||
|
||||
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;
|
||||
private:
|
||||
virtual EndpointOutcome endpoint()const override;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_STS_STSCLIENT_H_
|
||||
38
core/include/alibabacloud/core/sts/StsRequest.h
Normal file
38
core/include/alibabacloud/core/sts/StsRequest.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_STS_STSSERVICEREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_STS_STSSERVICEREQUEST_H_
|
||||
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT StsRequest : public RpcServiceRequest
|
||||
{
|
||||
public:
|
||||
explicit StsRequest(const std::string & action);
|
||||
virtual ~StsRequest();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_STS_STSSERVICEREQUEST_H_
|
||||
47
core/include/alibabacloud/core/sts/model/AssumeRoleRequest.h
Normal file
47
core/include/alibabacloud/core/sts/model/AssumeRoleRequest.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLEREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLEREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <alibabacloud/core/sts/StsRequest.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT AssumeRoleRequest : public StsRequest
|
||||
{
|
||||
public:
|
||||
AssumeRoleRequest();
|
||||
~AssumeRoleRequest();
|
||||
|
||||
int durationSeconds()const;
|
||||
std::string policy()const;
|
||||
std::string roleArn()const;
|
||||
std::string roleSessionName()const;
|
||||
void setDurationSeconds(int durationSeconds);
|
||||
void setPolicy(const std::string &policy);
|
||||
void setRoleArn(const std::string & roleArn);
|
||||
void setRoleSessionName(const std::string & roleSessionName);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLEREQUEST_H_
|
||||
59
core/include/alibabacloud/core/sts/model/AssumeRoleResult.h
Normal file
59
core/include/alibabacloud/core/sts/model/AssumeRoleResult.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLERESULT_H_
|
||||
#define ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLERESULT_H_
|
||||
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT AssumeRoleResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
struct AssumedRoleUser
|
||||
{
|
||||
std::string arn;
|
||||
std::string assumedRoleId;
|
||||
};
|
||||
struct Credentials
|
||||
{
|
||||
std::string accessKeyId;
|
||||
std::string accessKeySecret;
|
||||
std::string expiration;
|
||||
std::string securityToken;
|
||||
};
|
||||
|
||||
AssumeRoleResult();
|
||||
explicit AssumeRoleResult(const std::string &payload);
|
||||
~AssumeRoleResult();
|
||||
|
||||
AssumedRoleUser assumedRoleUser()const;
|
||||
Credentials credentials()const;
|
||||
private:
|
||||
void parse(const std::string &payload);
|
||||
|
||||
AssumedRoleUser assumedRoleUser_;
|
||||
Credentials credentials_;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_STS_MODEL_ASSUMEROLERESULT_H_
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYREQUEST_H_
|
||||
#define ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <alibabacloud/core/sts/StsRequest.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityRequest : public StsRequest
|
||||
{
|
||||
public:
|
||||
GetCallerIdentityRequest();
|
||||
~GetCallerIdentityRequest();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYREQUEST_H_
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYRESULT_H_
|
||||
#define ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYRESULT_H_
|
||||
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Sts
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CORE_EXPORT GetCallerIdentityResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
GetCallerIdentityResult();
|
||||
explicit GetCallerIdentityResult(const std::string &payload);
|
||||
~GetCallerIdentityResult();
|
||||
|
||||
std::string accountId();
|
||||
std::string arn()const;
|
||||
std::string userId()const;
|
||||
private:
|
||||
void parse(const std::string &payload);
|
||||
|
||||
std::string accountId_;
|
||||
std::string arn_;
|
||||
std::string userId_;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CORE_STS_MODEL_GETCALLERIDENTITYRESULT_H_
|
||||
Reference in New Issue
Block a user