由丰鲁成发起的CORE SDK自动发布, BUILD_ID=147, 版本号:1.0.9
发布日志: 1, Update InstanceProfileCredentialsProvider 2, Update common api
This commit is contained in:
@@ -27,7 +27,13 @@ namespace AlibabaCloud
|
||||
class ALIBABACLOUD_CORE_EXPORT CommonRequest : public ServiceRequest
|
||||
{
|
||||
public:
|
||||
CommonRequest();
|
||||
enum RequestPattern
|
||||
{
|
||||
RpcPattern,
|
||||
RoaPattern
|
||||
};
|
||||
|
||||
explicit CommonRequest(RequestPattern pattern = RpcPattern);
|
||||
~CommonRequest();
|
||||
|
||||
std::string domain()const;
|
||||
@@ -42,15 +48,15 @@ namespace AlibabaCloud
|
||||
void setHttpMethod(HttpRequest::Method method);
|
||||
void setQueryParameter(const ParameterNameType &name, const ParameterValueType &value);
|
||||
using ServiceRequest::setResourcePath;
|
||||
void setUriPattern(const std::string &uriPattern);
|
||||
void setRequestPattern(RequestPattern pattern);
|
||||
using ServiceRequest::setVersion;
|
||||
std::string uriPattern()const;
|
||||
RequestPattern requestPattern()const;
|
||||
protected:
|
||||
using ServiceRequest::product;
|
||||
|
||||
private:
|
||||
std::string domain_;
|
||||
std::string uriPattern_;
|
||||
RequestPattern requestPattern_;
|
||||
ParameterCollection queryParams_;
|
||||
ParameterCollection headerParams_;
|
||||
HttpRequest::Method httpMethod_;
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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_
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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_
|
||||
@@ -20,28 +20,31 @@
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "CredentialsProvider.h"
|
||||
#include "Credentials.h"
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
class EcsInstanceProfileConfigLoader;
|
||||
class InstanceProfileConfigLoader;
|
||||
{
|
||||
class EcsMetadataFetcher;
|
||||
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));
|
||||
InstanceProfileCredentialsProvider(const std::string &roleName, int durationSeconds = 3600);
|
||||
~InstanceProfileCredentialsProvider();
|
||||
|
||||
std::string roleName()const;
|
||||
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;
|
||||
void loadCredentials();
|
||||
bool checkExpiry()const;
|
||||
|
||||
std::mutex cachedMutex_;
|
||||
Credentials cachedCredentials_;
|
||||
int durationSeconds_;
|
||||
std::chrono::system_clock::time_point expiry_;
|
||||
EcsMetadataFetcher *fetcher_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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_
|
||||
Reference in New Issue
Block a user