feat(hos_client_create, hos_client_destory): 多次调用destory不会导致重复释放

This commit is contained in:
彭宣正
2020-12-14 17:24:58 +08:00
parent 505d529c32
commit 10b370e486
55976 changed files with 8544395 additions and 2 deletions

View File

@@ -0,0 +1,76 @@
add_project(aws-cpp-sdk-ec2-instance-connect "C++ SDK for the AWS ec2-instance-connect service" aws-cpp-sdk-core)
file(GLOB AWS_EC2-INSTANCE-CONNECT_HEADERS
"include/aws/ec2-instance-connect/*.h"
)
file(GLOB AWS_EC2-INSTANCE-CONNECT_MODEL_HEADERS
"include/aws/ec2-instance-connect/model/*.h"
)
file(GLOB AWS_EC2-INSTANCE-CONNECT_SOURCE
"source/*.cpp"
)
file(GLOB AWS_EC2-INSTANCE-CONNECT_MODEL_SOURCE
"source/model/*.cpp"
)
file(GLOB EC2-INSTANCE-CONNECT_UNIFIED_HEADERS
${AWS_EC2-INSTANCE-CONNECT_HEADERS}
${AWS_EC2-INSTANCE-CONNECT_MODEL_HEADERS}
)
file(GLOB EC2-INSTANCE-CONNECT_UNITY_SRC
${AWS_EC2-INSTANCE-CONNECT_SOURCE}
${AWS_EC2-INSTANCE-CONNECT_MODEL_SOURCE}
)
if(ENABLE_UNITY_BUILD)
enable_unity_build("EC2-INSTANCE-CONNECT" EC2-INSTANCE-CONNECT_UNITY_SRC)
endif()
file(GLOB EC2-INSTANCE-CONNECT_SRC
${EC2-INSTANCE-CONNECT_UNIFIED_HEADERS}
${EC2-INSTANCE-CONNECT_UNITY_SRC}
)
if(WIN32)
#if we are compiling for visual studio, create a sane directory tree.
if(MSVC)
source_group("Header Files\\aws\\ec2-instance-connect" FILES ${AWS_EC2-INSTANCE-CONNECT_HEADERS})
source_group("Header Files\\aws\\ec2-instance-connect\\model" FILES ${AWS_EC2-INSTANCE-CONNECT_MODEL_HEADERS})
source_group("Source Files" FILES ${AWS_EC2-INSTANCE-CONNECT_SOURCE})
source_group("Source Files\\model" FILES ${AWS_EC2-INSTANCE-CONNECT_MODEL_SOURCE})
endif(MSVC)
endif()
set(EC2-INSTANCE-CONNECT_INCLUDES
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
)
add_library(${PROJECT_NAME} ${EC2-INSTANCE-CONNECT_SRC})
add_library(AWS::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
set_compiler_flags(${PROJECT_NAME})
set_compiler_warnings(${PROJECT_NAME})
if(USE_WINDOWS_DLL_SEMANTICS AND BUILD_SHARED_LIBS)
target_compile_definitions(${PROJECT_NAME} PRIVATE "AWS_EC2INSTANCECONNECT_EXPORTS")
endif()
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(${PROJECT_NAME} PRIVATE ${PLATFORM_DEP_LIBS} ${PROJECT_LIBS})
setup_install()
install (FILES ${AWS_EC2-INSTANCE-CONNECT_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/ec2-instance-connect)
install (FILES ${AWS_EC2-INSTANCE-CONNECT_MODEL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/ec2-instance-connect/model)
do_packaging()

View File

@@ -0,0 +1,138 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/ec2-instance-connect/EC2InstanceConnect_EXPORTS.h>
#include <aws/ec2-instance-connect/EC2InstanceConnectErrors.h>
#include <aws/core/client/AWSError.h>
#include <aws/core/client/ClientConfiguration.h>
#include <aws/core/client/AWSClient.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/ec2-instance-connect/model/SendSSHPublicKeyResult.h>
#include <aws/core/client/AsyncCallerContext.h>
#include <aws/core/http/HttpTypes.h>
#include <future>
#include <functional>
namespace Aws
{
namespace Http
{
class HttpClient;
class HttpClientFactory;
} // namespace Http
namespace Utils
{
template< typename R, typename E> class Outcome;
namespace Threading
{
class Executor;
} // namespace Threading
} // namespace Utils
namespace Auth
{
class AWSCredentials;
class AWSCredentialsProvider;
} // namespace Auth
namespace Client
{
class RetryStrategy;
} // namespace Client
namespace EC2InstanceConnect
{
namespace Model
{
class SendSSHPublicKeyRequest;
typedef Aws::Utils::Outcome<SendSSHPublicKeyResult, EC2InstanceConnectError> SendSSHPublicKeyOutcome;
typedef std::future<SendSSHPublicKeyOutcome> SendSSHPublicKeyOutcomeCallable;
} // namespace Model
class EC2InstanceConnectClient;
typedef std::function<void(const EC2InstanceConnectClient*, const Model::SendSSHPublicKeyRequest&, const Model::SendSSHPublicKeyOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) > SendSSHPublicKeyResponseReceivedHandler;
/**
* <p>AWS EC2 Connect Service is a service that enables system administrators to
* publish temporary SSH keys to their EC2 instances in order to establish
* connections to their instances without leaving a permanent authentication
* option.</p>
*/
class AWS_EC2INSTANCECONNECT_API EC2InstanceConnectClient : public Aws::Client::AWSJsonClient
{
public:
typedef Aws::Client::AWSJsonClient BASECLASS;
/**
* Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config
* is not specified, it will be initialized to default values.
*/
EC2InstanceConnectClient(const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
/**
* Initializes client to use SimpleAWSCredentialsProvider, with default http client factory, and optional client config. If client config
* is not specified, it will be initialized to default values.
*/
EC2InstanceConnectClient(const Aws::Auth::AWSCredentials& credentials, const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
/**
* Initializes client to use specified credentials provider with specified client config. If http client factory is not supplied,
* the default http client factory will be used
*/
EC2InstanceConnectClient(const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& credentialsProvider,
const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration());
virtual ~EC2InstanceConnectClient();
/**
* <p>Pushes an SSH public key to a particular OS user on a given EC2 instance for
* 60 seconds.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/ec2-instance-connect-2018-04-02/SendSSHPublicKey">AWS
* API Reference</a></p>
*/
virtual Model::SendSSHPublicKeyOutcome SendSSHPublicKey(const Model::SendSSHPublicKeyRequest& request) const;
/**
* <p>Pushes an SSH public key to a particular OS user on a given EC2 instance for
* 60 seconds.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/ec2-instance-connect-2018-04-02/SendSSHPublicKey">AWS
* API Reference</a></p>
*
* returns a future to the operation so that it can be executed in parallel to other requests.
*/
virtual Model::SendSSHPublicKeyOutcomeCallable SendSSHPublicKeyCallable(const Model::SendSSHPublicKeyRequest& request) const;
/**
* <p>Pushes an SSH public key to a particular OS user on a given EC2 instance for
* 60 seconds.</p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/ec2-instance-connect-2018-04-02/SendSSHPublicKey">AWS
* API Reference</a></p>
*
* Queues the request into a thread executor and triggers associated callback when operation has finished.
*/
virtual void SendSSHPublicKeyAsync(const Model::SendSSHPublicKeyRequest& request, const SendSSHPublicKeyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context = nullptr) const;
void OverrideEndpoint(const Aws::String& endpoint);
private:
void init(const Aws::Client::ClientConfiguration& clientConfiguration);
void SendSSHPublicKeyAsyncHelper(const Model::SendSSHPublicKeyRequest& request, const SendSSHPublicKeyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const;
Aws::String m_uri;
Aws::String m_configScheme;
std::shared_ptr<Aws::Utils::Threading::Executor> m_executor;
};
} // namespace EC2InstanceConnect
} // namespace Aws

View File

@@ -0,0 +1,21 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/ec2-instance-connect/EC2InstanceConnect_EXPORTS.h>
#include <aws/core/Region.h>
#include <aws/core/utils/memory/stl/AWSString.h>
namespace Aws
{
namespace EC2InstanceConnect
{
namespace EC2InstanceConnectEndpoint
{
AWS_EC2INSTANCECONNECT_API Aws::String ForRegion(const Aws::String& regionName, bool useDualStack = false);
} // namespace EC2InstanceConnectEndpoint
} // namespace EC2InstanceConnect
} // namespace Aws

View File

@@ -0,0 +1,23 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/ec2-instance-connect/EC2InstanceConnect_EXPORTS.h>
#include <aws/core/client/AWSErrorMarshaller.h>
namespace Aws
{
namespace Client
{
class AWS_EC2INSTANCECONNECT_API EC2InstanceConnectErrorMarshaller : public Aws::Client::JsonErrorMarshaller
{
public:
Aws::Client::AWSError<Aws::Client::CoreErrors> FindErrorByName(const char* exceptionName) const override;
};
} // namespace Client
} // namespace Aws

View File

@@ -0,0 +1,75 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/core/client/AWSError.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/ec2-instance-connect/EC2InstanceConnect_EXPORTS.h>
namespace Aws
{
namespace EC2InstanceConnect
{
enum class EC2InstanceConnectErrors
{
//From Core//
//////////////////////////////////////////////////////////////////////////////////////////
INCOMPLETE_SIGNATURE = 0,
INTERNAL_FAILURE = 1,
INVALID_ACTION = 2,
INVALID_CLIENT_TOKEN_ID = 3,
INVALID_PARAMETER_COMBINATION = 4,
INVALID_QUERY_PARAMETER = 5,
INVALID_PARAMETER_VALUE = 6,
MISSING_ACTION = 7, // SDK should never allow
MISSING_AUTHENTICATION_TOKEN = 8, // SDK should never allow
MISSING_PARAMETER = 9, // SDK should never allow
OPT_IN_REQUIRED = 10,
REQUEST_EXPIRED = 11,
SERVICE_UNAVAILABLE = 12,
THROTTLING = 13,
VALIDATION = 14,
ACCESS_DENIED = 15,
RESOURCE_NOT_FOUND = 16,
UNRECOGNIZED_CLIENT = 17,
MALFORMED_QUERY_STRING = 18,
SLOW_DOWN = 19,
REQUEST_TIME_TOO_SKEWED = 20,
INVALID_SIGNATURE = 21,
SIGNATURE_DOES_NOT_MATCH = 22,
INVALID_ACCESS_KEY_ID = 23,
REQUEST_TIMEOUT = 24,
NETWORK_CONNECTION = 99,
UNKNOWN = 100,
///////////////////////////////////////////////////////////////////////////////////////////
AUTH= static_cast<int>(Aws::Client::CoreErrors::SERVICE_EXTENSION_START_RANGE) + 1,
E_C2_INSTANCE_NOT_FOUND,
INVALID_ARGS,
SERVICE
};
class AWS_EC2INSTANCECONNECT_API EC2InstanceConnectError : public Aws::Client::AWSError<EC2InstanceConnectErrors>
{
public:
EC2InstanceConnectError() {}
EC2InstanceConnectError(const Aws::Client::AWSError<Aws::Client::CoreErrors>& rhs) : Aws::Client::AWSError<EC2InstanceConnectErrors>(rhs) {}
EC2InstanceConnectError(Aws::Client::AWSError<Aws::Client::CoreErrors>&& rhs) : Aws::Client::AWSError<EC2InstanceConnectErrors>(rhs) {}
EC2InstanceConnectError(const Aws::Client::AWSError<EC2InstanceConnectErrors>& rhs) : Aws::Client::AWSError<EC2InstanceConnectErrors>(rhs) {}
EC2InstanceConnectError(Aws::Client::AWSError<EC2InstanceConnectErrors>&& rhs) : Aws::Client::AWSError<EC2InstanceConnectErrors>(rhs) {}
template <typename T>
T GetModeledError();
};
namespace EC2InstanceConnectErrorMapper
{
AWS_EC2INSTANCECONNECT_API Aws::Client::AWSError<Aws::Client::CoreErrors> GetErrorForName(const char* errorName);
}
} // namespace EC2InstanceConnect
} // namespace Aws

View File

@@ -0,0 +1,42 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/ec2-instance-connect/EC2InstanceConnect_EXPORTS.h>
#include <aws/core/AmazonSerializableWebServiceRequest.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <aws/core/http/HttpRequest.h>
namespace Aws
{
namespace EC2InstanceConnect
{
class AWS_EC2INSTANCECONNECT_API EC2InstanceConnectRequest : public Aws::AmazonSerializableWebServiceRequest
{
public:
virtual ~EC2InstanceConnectRequest () {}
void AddParametersToRequest(Aws::Http::HttpRequest& httpRequest) const { AWS_UNREFERENCED_PARAM(httpRequest); }
inline Aws::Http::HeaderValueCollection GetHeaders() const override
{
auto headers = GetRequestSpecificHeaders();
if(headers.size() == 0 || (headers.size() > 0 && headers.count(Aws::Http::CONTENT_TYPE_HEADER) == 0))
{
headers.emplace(Aws::Http::HeaderValuePair(Aws::Http::CONTENT_TYPE_HEADER, Aws::AMZN_JSON_CONTENT_TYPE_1_1 ));
}
headers.emplace(Aws::Http::HeaderValuePair(Aws::Http::API_VERSION_HEADER, "2018-04-02"));
return headers;
}
protected:
virtual Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const { return Aws::Http::HeaderValueCollection(); }
};
} // namespace EC2InstanceConnect
} // namespace Aws

View File

@@ -0,0 +1,29 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#ifdef _MSC_VER
//disable windows complaining about max template size.
#pragma warning (disable : 4503)
#endif // _MSC_VER
#if defined (USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32)
#ifdef _MSC_VER
#pragma warning(disable : 4251)
#endif // _MSC_VER
#ifdef USE_IMPORT_EXPORT
#ifdef AWS_EC2INSTANCECONNECT_EXPORTS
#define AWS_EC2INSTANCECONNECT_API __declspec(dllexport)
#else
#define AWS_EC2INSTANCECONNECT_API __declspec(dllimport)
#endif /* AWS_EC2INSTANCECONNECT_EXPORTS */
#else
#define AWS_EC2INSTANCECONNECT_API
#endif // USE_IMPORT_EXPORT
#else // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (WIN32)
#define AWS_EC2INSTANCECONNECT_API
#endif // defined (USE_WINDOWS_DLL_SEMANTICS) || defined (WIN32)

View File

@@ -0,0 +1,233 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/ec2-instance-connect/EC2InstanceConnect_EXPORTS.h>
#include <aws/ec2-instance-connect/EC2InstanceConnectRequest.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>
namespace Aws
{
namespace EC2InstanceConnect
{
namespace Model
{
/**
*/
class AWS_EC2INSTANCECONNECT_API SendSSHPublicKeyRequest : public EC2InstanceConnectRequest
{
public:
SendSSHPublicKeyRequest();
// Service request name is the Operation name which will send this request out,
// each operation should has unique request name, so that we can get operation's name from this request.
// Note: this is not true for response, multiple operations may have the same response name,
// so we can not get operation's name from response.
inline virtual const char* GetServiceRequestName() const override { return "SendSSHPublicKey"; }
Aws::String SerializePayload() const override;
Aws::Http::HeaderValueCollection GetRequestSpecificHeaders() const override;
/**
* <p>The EC2 instance you wish to publish the SSH key to.</p>
*/
inline const Aws::String& GetInstanceId() const{ return m_instanceId; }
/**
* <p>The EC2 instance you wish to publish the SSH key to.</p>
*/
inline bool InstanceIdHasBeenSet() const { return m_instanceIdHasBeenSet; }
/**
* <p>The EC2 instance you wish to publish the SSH key to.</p>
*/
inline void SetInstanceId(const Aws::String& value) { m_instanceIdHasBeenSet = true; m_instanceId = value; }
/**
* <p>The EC2 instance you wish to publish the SSH key to.</p>
*/
inline void SetInstanceId(Aws::String&& value) { m_instanceIdHasBeenSet = true; m_instanceId = std::move(value); }
/**
* <p>The EC2 instance you wish to publish the SSH key to.</p>
*/
inline void SetInstanceId(const char* value) { m_instanceIdHasBeenSet = true; m_instanceId.assign(value); }
/**
* <p>The EC2 instance you wish to publish the SSH key to.</p>
*/
inline SendSSHPublicKeyRequest& WithInstanceId(const Aws::String& value) { SetInstanceId(value); return *this;}
/**
* <p>The EC2 instance you wish to publish the SSH key to.</p>
*/
inline SendSSHPublicKeyRequest& WithInstanceId(Aws::String&& value) { SetInstanceId(std::move(value)); return *this;}
/**
* <p>The EC2 instance you wish to publish the SSH key to.</p>
*/
inline SendSSHPublicKeyRequest& WithInstanceId(const char* value) { SetInstanceId(value); return *this;}
/**
* <p>The OS user on the EC2 instance whom the key may be used to authenticate
* as.</p>
*/
inline const Aws::String& GetInstanceOSUser() const{ return m_instanceOSUser; }
/**
* <p>The OS user on the EC2 instance whom the key may be used to authenticate
* as.</p>
*/
inline bool InstanceOSUserHasBeenSet() const { return m_instanceOSUserHasBeenSet; }
/**
* <p>The OS user on the EC2 instance whom the key may be used to authenticate
* as.</p>
*/
inline void SetInstanceOSUser(const Aws::String& value) { m_instanceOSUserHasBeenSet = true; m_instanceOSUser = value; }
/**
* <p>The OS user on the EC2 instance whom the key may be used to authenticate
* as.</p>
*/
inline void SetInstanceOSUser(Aws::String&& value) { m_instanceOSUserHasBeenSet = true; m_instanceOSUser = std::move(value); }
/**
* <p>The OS user on the EC2 instance whom the key may be used to authenticate
* as.</p>
*/
inline void SetInstanceOSUser(const char* value) { m_instanceOSUserHasBeenSet = true; m_instanceOSUser.assign(value); }
/**
* <p>The OS user on the EC2 instance whom the key may be used to authenticate
* as.</p>
*/
inline SendSSHPublicKeyRequest& WithInstanceOSUser(const Aws::String& value) { SetInstanceOSUser(value); return *this;}
/**
* <p>The OS user on the EC2 instance whom the key may be used to authenticate
* as.</p>
*/
inline SendSSHPublicKeyRequest& WithInstanceOSUser(Aws::String&& value) { SetInstanceOSUser(std::move(value)); return *this;}
/**
* <p>The OS user on the EC2 instance whom the key may be used to authenticate
* as.</p>
*/
inline SendSSHPublicKeyRequest& WithInstanceOSUser(const char* value) { SetInstanceOSUser(value); return *this;}
/**
* <p>The public key to be published to the instance. To use it after publication
* you must have the matching private key.</p>
*/
inline const Aws::String& GetSSHPublicKey() const{ return m_sSHPublicKey; }
/**
* <p>The public key to be published to the instance. To use it after publication
* you must have the matching private key.</p>
*/
inline bool SSHPublicKeyHasBeenSet() const { return m_sSHPublicKeyHasBeenSet; }
/**
* <p>The public key to be published to the instance. To use it after publication
* you must have the matching private key.</p>
*/
inline void SetSSHPublicKey(const Aws::String& value) { m_sSHPublicKeyHasBeenSet = true; m_sSHPublicKey = value; }
/**
* <p>The public key to be published to the instance. To use it after publication
* you must have the matching private key.</p>
*/
inline void SetSSHPublicKey(Aws::String&& value) { m_sSHPublicKeyHasBeenSet = true; m_sSHPublicKey = std::move(value); }
/**
* <p>The public key to be published to the instance. To use it after publication
* you must have the matching private key.</p>
*/
inline void SetSSHPublicKey(const char* value) { m_sSHPublicKeyHasBeenSet = true; m_sSHPublicKey.assign(value); }
/**
* <p>The public key to be published to the instance. To use it after publication
* you must have the matching private key.</p>
*/
inline SendSSHPublicKeyRequest& WithSSHPublicKey(const Aws::String& value) { SetSSHPublicKey(value); return *this;}
/**
* <p>The public key to be published to the instance. To use it after publication
* you must have the matching private key.</p>
*/
inline SendSSHPublicKeyRequest& WithSSHPublicKey(Aws::String&& value) { SetSSHPublicKey(std::move(value)); return *this;}
/**
* <p>The public key to be published to the instance. To use it after publication
* you must have the matching private key.</p>
*/
inline SendSSHPublicKeyRequest& WithSSHPublicKey(const char* value) { SetSSHPublicKey(value); return *this;}
/**
* <p>The availability zone the EC2 instance was launched in.</p>
*/
inline const Aws::String& GetAvailabilityZone() const{ return m_availabilityZone; }
/**
* <p>The availability zone the EC2 instance was launched in.</p>
*/
inline bool AvailabilityZoneHasBeenSet() const { return m_availabilityZoneHasBeenSet; }
/**
* <p>The availability zone the EC2 instance was launched in.</p>
*/
inline void SetAvailabilityZone(const Aws::String& value) { m_availabilityZoneHasBeenSet = true; m_availabilityZone = value; }
/**
* <p>The availability zone the EC2 instance was launched in.</p>
*/
inline void SetAvailabilityZone(Aws::String&& value) { m_availabilityZoneHasBeenSet = true; m_availabilityZone = std::move(value); }
/**
* <p>The availability zone the EC2 instance was launched in.</p>
*/
inline void SetAvailabilityZone(const char* value) { m_availabilityZoneHasBeenSet = true; m_availabilityZone.assign(value); }
/**
* <p>The availability zone the EC2 instance was launched in.</p>
*/
inline SendSSHPublicKeyRequest& WithAvailabilityZone(const Aws::String& value) { SetAvailabilityZone(value); return *this;}
/**
* <p>The availability zone the EC2 instance was launched in.</p>
*/
inline SendSSHPublicKeyRequest& WithAvailabilityZone(Aws::String&& value) { SetAvailabilityZone(std::move(value)); return *this;}
/**
* <p>The availability zone the EC2 instance was launched in.</p>
*/
inline SendSSHPublicKeyRequest& WithAvailabilityZone(const char* value) { SetAvailabilityZone(value); return *this;}
private:
Aws::String m_instanceId;
bool m_instanceIdHasBeenSet;
Aws::String m_instanceOSUser;
bool m_instanceOSUserHasBeenSet;
Aws::String m_sSHPublicKey;
bool m_sSHPublicKeyHasBeenSet;
Aws::String m_availabilityZone;
bool m_availabilityZoneHasBeenSet;
};
} // namespace Model
} // namespace EC2InstanceConnect
} // namespace Aws

View File

@@ -0,0 +1,102 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/ec2-instance-connect/EC2InstanceConnect_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>
namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;
namespace Utils
{
namespace Json
{
class JsonValue;
} // namespace Json
} // namespace Utils
namespace EC2InstanceConnect
{
namespace Model
{
class AWS_EC2INSTANCECONNECT_API SendSSHPublicKeyResult
{
public:
SendSSHPublicKeyResult();
SendSSHPublicKeyResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
SendSSHPublicKeyResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
/**
* <p>The request ID as logged by EC2 Connect. Please provide this when contacting
* AWS Support.</p>
*/
inline const Aws::String& GetRequestId() const{ return m_requestId; }
/**
* <p>The request ID as logged by EC2 Connect. Please provide this when contacting
* AWS Support.</p>
*/
inline void SetRequestId(const Aws::String& value) { m_requestId = value; }
/**
* <p>The request ID as logged by EC2 Connect. Please provide this when contacting
* AWS Support.</p>
*/
inline void SetRequestId(Aws::String&& value) { m_requestId = std::move(value); }
/**
* <p>The request ID as logged by EC2 Connect. Please provide this when contacting
* AWS Support.</p>
*/
inline void SetRequestId(const char* value) { m_requestId.assign(value); }
/**
* <p>The request ID as logged by EC2 Connect. Please provide this when contacting
* AWS Support.</p>
*/
inline SendSSHPublicKeyResult& WithRequestId(const Aws::String& value) { SetRequestId(value); return *this;}
/**
* <p>The request ID as logged by EC2 Connect. Please provide this when contacting
* AWS Support.</p>
*/
inline SendSSHPublicKeyResult& WithRequestId(Aws::String&& value) { SetRequestId(std::move(value)); return *this;}
/**
* <p>The request ID as logged by EC2 Connect. Please provide this when contacting
* AWS Support.</p>
*/
inline SendSSHPublicKeyResult& WithRequestId(const char* value) { SetRequestId(value); return *this;}
/**
* <p>Indicates request success.</p>
*/
inline bool GetSuccess() const{ return m_success; }
/**
* <p>Indicates request success.</p>
*/
inline void SetSuccess(bool value) { m_success = value; }
/**
* <p>Indicates request success.</p>
*/
inline SendSSHPublicKeyResult& WithSuccess(bool value) { SetSuccess(value); return *this;}
private:
Aws::String m_requestId;
bool m_success;
};
} // namespace Model
} // namespace EC2InstanceConnect
} // namespace Aws

View File

@@ -0,0 +1,124 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/utils/Outcome.h>
#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/core/client/RetryStrategy.h>
#include <aws/core/http/HttpClient.h>
#include <aws/core/http/HttpResponse.h>
#include <aws/core/http/HttpClientFactory.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/threading/Executor.h>
#include <aws/core/utils/DNS.h>
#include <aws/core/utils/logging/LogMacros.h>
#include <aws/ec2-instance-connect/EC2InstanceConnectClient.h>
#include <aws/ec2-instance-connect/EC2InstanceConnectEndpoint.h>
#include <aws/ec2-instance-connect/EC2InstanceConnectErrorMarshaller.h>
#include <aws/ec2-instance-connect/model/SendSSHPublicKeyRequest.h>
using namespace Aws;
using namespace Aws::Auth;
using namespace Aws::Client;
using namespace Aws::EC2InstanceConnect;
using namespace Aws::EC2InstanceConnect::Model;
using namespace Aws::Http;
using namespace Aws::Utils::Json;
static const char* SERVICE_NAME = "ec2-instance-connect";
static const char* ALLOCATION_TAG = "EC2InstanceConnectClient";
EC2InstanceConnectClient::EC2InstanceConnectClient(const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG),
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<EC2InstanceConnectErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
EC2InstanceConnectClient::EC2InstanceConnectClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<SimpleAWSCredentialsProvider>(ALLOCATION_TAG, credentials),
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<EC2InstanceConnectErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
EC2InstanceConnectClient::EC2InstanceConnectClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, credentialsProvider,
SERVICE_NAME, Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<EC2InstanceConnectErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
EC2InstanceConnectClient::~EC2InstanceConnectClient()
{
}
void EC2InstanceConnectClient::init(const ClientConfiguration& config)
{
SetServiceClientName("EC2 Instance Connect");
m_configScheme = SchemeMapper::ToString(config.scheme);
if (config.endpointOverride.empty())
{
m_uri = m_configScheme + "://" + EC2InstanceConnectEndpoint::ForRegion(config.region, config.useDualStack);
}
else
{
OverrideEndpoint(config.endpointOverride);
}
}
void EC2InstanceConnectClient::OverrideEndpoint(const Aws::String& endpoint)
{
if (endpoint.compare(0, 7, "http://") == 0 || endpoint.compare(0, 8, "https://") == 0)
{
m_uri = endpoint;
}
else
{
m_uri = m_configScheme + "://" + endpoint;
}
}
SendSSHPublicKeyOutcome EC2InstanceConnectClient::SendSSHPublicKey(const SendSSHPublicKeyRequest& request) const
{
Aws::Http::URI uri = m_uri;
Aws::StringStream ss;
ss << "/";
uri.SetPath(uri.GetPath() + ss.str());
return SendSSHPublicKeyOutcome(MakeRequest(uri, request, Aws::Http::HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER));
}
SendSSHPublicKeyOutcomeCallable EC2InstanceConnectClient::SendSSHPublicKeyCallable(const SendSSHPublicKeyRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< SendSSHPublicKeyOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->SendSSHPublicKey(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void EC2InstanceConnectClient::SendSSHPublicKeyAsync(const SendSSHPublicKeyRequest& request, const SendSSHPublicKeyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->SendSSHPublicKeyAsyncHelper( request, handler, context ); } );
}
void EC2InstanceConnectClient::SendSSHPublicKeyAsyncHelper(const SendSSHPublicKeyRequest& request, const SendSSHPublicKeyResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, SendSSHPublicKey(request), context);
}

View File

@@ -0,0 +1,64 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/ec2-instance-connect/EC2InstanceConnectEndpoint.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/HashingUtils.h>
using namespace Aws;
using namespace Aws::EC2InstanceConnect;
namespace Aws
{
namespace EC2InstanceConnect
{
namespace EC2InstanceConnectEndpoint
{
static const int CN_NORTH_1_HASH = Aws::Utils::HashingUtils::HashString("cn-north-1");
static const int CN_NORTHWEST_1_HASH = Aws::Utils::HashingUtils::HashString("cn-northwest-1");
static const int US_ISO_EAST_1_HASH = Aws::Utils::HashingUtils::HashString("us-iso-east-1");
static const int US_ISOB_EAST_1_HASH = Aws::Utils::HashingUtils::HashString("us-isob-east-1");
Aws::String ForRegion(const Aws::String& regionName, bool useDualStack)
{
// Fallback to us-east-1 if global endpoint does not exists.
Aws::String region = regionName == Aws::Region::AWS_GLOBAL ? Aws::Region::US_EAST_1 : regionName;
auto hash = Aws::Utils::HashingUtils::HashString(region.c_str());
Aws::StringStream ss;
ss << "ec2-instance-connect" << ".";
if(useDualStack)
{
ss << "dualstack.";
}
ss << region;
if (hash == CN_NORTH_1_HASH || hash == CN_NORTHWEST_1_HASH)
{
ss << ".amazonaws.com.cn";
}
else if (hash == US_ISO_EAST_1_HASH)
{
ss << ".c2s.ic.gov";
}
else if (hash == US_ISOB_EAST_1_HASH)
{
ss << ".sc2s.sgov.gov";
}
else
{
ss << ".amazonaws.com";
}
return ss.str();
}
} // namespace EC2InstanceConnectEndpoint
} // namespace EC2InstanceConnect
} // namespace Aws

View File

@@ -0,0 +1,22 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/client/AWSError.h>
#include <aws/ec2-instance-connect/EC2InstanceConnectErrorMarshaller.h>
#include <aws/ec2-instance-connect/EC2InstanceConnectErrors.h>
using namespace Aws::Client;
using namespace Aws::EC2InstanceConnect;
AWSError<CoreErrors> EC2InstanceConnectErrorMarshaller::FindErrorByName(const char* errorName) const
{
AWSError<CoreErrors> error = EC2InstanceConnectErrorMapper::GetErrorForName(errorName);
if(error.GetErrorType() != CoreErrors::UNKNOWN)
{
return error;
}
return AWSErrorMarshaller::FindErrorByName(errorName);
}

View File

@@ -0,0 +1,52 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/client/AWSError.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/ec2-instance-connect/EC2InstanceConnectErrors.h>
using namespace Aws::Client;
using namespace Aws::Utils;
using namespace Aws::EC2InstanceConnect;
namespace Aws
{
namespace EC2InstanceConnect
{
namespace EC2InstanceConnectErrorMapper
{
static const int INVALID_ARGS_HASH = HashingUtils::HashString("InvalidArgsException");
static const int SERVICE_HASH = HashingUtils::HashString("ServiceException");
static const int AUTH_HASH = HashingUtils::HashString("AuthException");
static const int E_C2_INSTANCE_NOT_FOUND_HASH = HashingUtils::HashString("EC2InstanceNotFoundException");
AWSError<CoreErrors> GetErrorForName(const char* errorName)
{
int hashCode = HashingUtils::HashString(errorName);
if (hashCode == INVALID_ARGS_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(EC2InstanceConnectErrors::INVALID_ARGS), false);
}
else if (hashCode == SERVICE_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(EC2InstanceConnectErrors::SERVICE), false);
}
else if (hashCode == AUTH_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(EC2InstanceConnectErrors::AUTH), false);
}
else if (hashCode == E_C2_INSTANCE_NOT_FOUND_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(EC2InstanceConnectErrors::E_C2_INSTANCE_NOT_FOUND), false);
}
return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
}
} // namespace EC2InstanceConnectErrorMapper
} // namespace EC2InstanceConnect
} // namespace Aws

View File

@@ -0,0 +1,64 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/ec2-instance-connect/model/SendSSHPublicKeyRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::EC2InstanceConnect::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
SendSSHPublicKeyRequest::SendSSHPublicKeyRequest() :
m_instanceIdHasBeenSet(false),
m_instanceOSUserHasBeenSet(false),
m_sSHPublicKeyHasBeenSet(false),
m_availabilityZoneHasBeenSet(false)
{
}
Aws::String SendSSHPublicKeyRequest::SerializePayload() const
{
JsonValue payload;
if(m_instanceIdHasBeenSet)
{
payload.WithString("InstanceId", m_instanceId);
}
if(m_instanceOSUserHasBeenSet)
{
payload.WithString("InstanceOSUser", m_instanceOSUser);
}
if(m_sSHPublicKeyHasBeenSet)
{
payload.WithString("SSHPublicKey", m_sSHPublicKey);
}
if(m_availabilityZoneHasBeenSet)
{
payload.WithString("AvailabilityZone", m_availabilityZone);
}
return payload.View().WriteReadable();
}
Aws::Http::HeaderValueCollection SendSSHPublicKeyRequest::GetRequestSpecificHeaders() const
{
Aws::Http::HeaderValueCollection headers;
headers.insert(Aws::Http::HeaderValuePair("X-Amz-Target", "AWSEC2InstanceConnectService.SendSSHPublicKey"));
return headers;
}

View File

@@ -0,0 +1,48 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/ec2-instance-connect/model/SendSSHPublicKeyResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::EC2InstanceConnect::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
SendSSHPublicKeyResult::SendSSHPublicKeyResult() :
m_success(false)
{
}
SendSSHPublicKeyResult::SendSSHPublicKeyResult(const Aws::AmazonWebServiceResult<JsonValue>& result) :
m_success(false)
{
*this = result;
}
SendSSHPublicKeyResult& SendSSHPublicKeyResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
JsonView jsonValue = result.GetPayload().View();
if(jsonValue.ValueExists("RequestId"))
{
m_requestId = jsonValue.GetString("RequestId");
}
if(jsonValue.ValueExists("Success"))
{
m_success = jsonValue.GetBool("Success");
}
return *this;
}