use std::error::Error;
use std::fmt;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError, RusotoFuture};
use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
use serde_json;
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Backup {
#[serde(rename = "BackupId")]
pub backup_id: String,
#[serde(rename = "BackupState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_state: Option<String>,
#[serde(rename = "ClusterId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cluster_id: Option<String>,
#[serde(rename = "CopyTimestamp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub copy_timestamp: Option<f64>,
#[serde(rename = "CreateTimestamp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub create_timestamp: Option<f64>,
#[serde(rename = "DeleteTimestamp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub delete_timestamp: Option<f64>,
#[serde(rename = "SourceBackup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_backup: Option<String>,
#[serde(rename = "SourceCluster")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_cluster: Option<String>,
#[serde(rename = "SourceRegion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_region: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Certificates {
#[serde(rename = "AwsHardwareCertificate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub aws_hardware_certificate: Option<String>,
#[serde(rename = "ClusterCertificate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cluster_certificate: Option<String>,
#[serde(rename = "ClusterCsr")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cluster_csr: Option<String>,
#[serde(rename = "HsmCertificate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hsm_certificate: Option<String>,
#[serde(rename = "ManufacturerHardwareCertificate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manufacturer_hardware_certificate: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Cluster {
#[serde(rename = "BackupPolicy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_policy: Option<String>,
#[serde(rename = "Certificates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificates: Option<Certificates>,
#[serde(rename = "ClusterId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cluster_id: Option<String>,
#[serde(rename = "CreateTimestamp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub create_timestamp: Option<f64>,
#[serde(rename = "HsmType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hsm_type: Option<String>,
#[serde(rename = "Hsms")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hsms: Option<Vec<Hsm>>,
#[serde(rename = "PreCoPassword")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pre_co_password: Option<String>,
#[serde(rename = "SecurityGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_group: Option<String>,
#[serde(rename = "SourceBackupId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_backup_id: Option<String>,
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "StateMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state_message: Option<String>,
#[serde(rename = "SubnetMapping")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subnet_mapping: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "VpcId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpc_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CopyBackupToRegionRequest {
#[serde(rename = "BackupId")]
pub backup_id: String,
#[serde(rename = "DestinationRegion")]
pub destination_region: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CopyBackupToRegionResponse {
#[serde(rename = "DestinationBackup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub destination_backup: Option<DestinationBackup>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateClusterRequest {
#[serde(rename = "HsmType")]
pub hsm_type: String,
#[serde(rename = "SourceBackupId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_backup_id: Option<String>,
#[serde(rename = "SubnetIds")]
pub subnet_ids: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateClusterResponse {
#[serde(rename = "Cluster")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cluster: Option<Cluster>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateHsmRequest {
#[serde(rename = "AvailabilityZone")]
pub availability_zone: String,
#[serde(rename = "ClusterId")]
pub cluster_id: String,
#[serde(rename = "IpAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateHsmResponse {
#[serde(rename = "Hsm")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hsm: Option<Hsm>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteBackupRequest {
#[serde(rename = "BackupId")]
pub backup_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteBackupResponse {
#[serde(rename = "Backup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup: Option<Backup>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteClusterRequest {
#[serde(rename = "ClusterId")]
pub cluster_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteClusterResponse {
#[serde(rename = "Cluster")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cluster: Option<Cluster>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteHsmRequest {
#[serde(rename = "ClusterId")]
pub cluster_id: String,
#[serde(rename = "EniId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub eni_id: Option<String>,
#[serde(rename = "EniIp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub eni_ip: Option<String>,
#[serde(rename = "HsmId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hsm_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteHsmResponse {
#[serde(rename = "HsmId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hsm_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeBackupsRequest {
#[serde(rename = "Filters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filters: Option<::std::collections::HashMap<String, Vec<String>>>,
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "SortAscending")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sort_ascending: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeBackupsResponse {
#[serde(rename = "Backups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backups: Option<Vec<Backup>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeClustersRequest {
#[serde(rename = "Filters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filters: Option<::std::collections::HashMap<String, Vec<String>>>,
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeClustersResponse {
#[serde(rename = "Clusters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub clusters: Option<Vec<Cluster>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DestinationBackup {
#[serde(rename = "CreateTimestamp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub create_timestamp: Option<f64>,
#[serde(rename = "SourceBackup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_backup: Option<String>,
#[serde(rename = "SourceCluster")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_cluster: Option<String>,
#[serde(rename = "SourceRegion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_region: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Hsm {
#[serde(rename = "AvailabilityZone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub availability_zone: Option<String>,
#[serde(rename = "ClusterId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cluster_id: Option<String>,
#[serde(rename = "EniId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub eni_id: Option<String>,
#[serde(rename = "EniIp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub eni_ip: Option<String>,
#[serde(rename = "HsmId")]
pub hsm_id: String,
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "StateMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state_message: Option<String>,
#[serde(rename = "SubnetId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subnet_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct InitializeClusterRequest {
#[serde(rename = "ClusterId")]
pub cluster_id: String,
#[serde(rename = "SignedCert")]
pub signed_cert: String,
#[serde(rename = "TrustAnchor")]
pub trust_anchor: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct InitializeClusterResponse {
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "StateMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state_message: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListTagsRequest {
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "ResourceId")]
pub resource_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListTagsResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "TagList")]
pub tag_list: Vec<Tag>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RestoreBackupRequest {
#[serde(rename = "BackupId")]
pub backup_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct RestoreBackupResponse {
#[serde(rename = "Backup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup: Option<Backup>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Tag {
#[serde(rename = "Key")]
pub key: String,
#[serde(rename = "Value")]
pub value: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct TagResourceRequest {
#[serde(rename = "ResourceId")]
pub resource_id: String,
#[serde(rename = "TagList")]
pub tag_list: Vec<Tag>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TagResourceResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UntagResourceRequest {
#[serde(rename = "ResourceId")]
pub resource_id: String,
#[serde(rename = "TagKeyList")]
pub tag_key_list: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UntagResourceResponse {}
#[derive(Debug, PartialEq)]
pub enum CopyBackupToRegionError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl CopyBackupToRegionError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CopyBackupToRegionError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(CopyBackupToRegionError::CloudHsmAccessDenied(
err.msg,
))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(CopyBackupToRegionError::CloudHsmInternalFailure(
err.msg,
))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(CopyBackupToRegionError::CloudHsmInvalidRequest(
err.msg,
))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(CopyBackupToRegionError::CloudHsmResourceNotFound(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(CopyBackupToRegionError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for CopyBackupToRegionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CopyBackupToRegionError {
fn description(&self) -> &str {
match *self {
CopyBackupToRegionError::CloudHsmAccessDenied(ref cause) => cause,
CopyBackupToRegionError::CloudHsmInternalFailure(ref cause) => cause,
CopyBackupToRegionError::CloudHsmInvalidRequest(ref cause) => cause,
CopyBackupToRegionError::CloudHsmResourceNotFound(ref cause) => cause,
CopyBackupToRegionError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateClusterError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl CreateClusterError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateClusterError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(CreateClusterError::CloudHsmAccessDenied(err.msg))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(CreateClusterError::CloudHsmInternalFailure(
err.msg,
))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(CreateClusterError::CloudHsmInvalidRequest(
err.msg,
))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(CreateClusterError::CloudHsmResourceNotFound(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(CreateClusterError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for CreateClusterError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateClusterError {
fn description(&self) -> &str {
match *self {
CreateClusterError::CloudHsmAccessDenied(ref cause) => cause,
CreateClusterError::CloudHsmInternalFailure(ref cause) => cause,
CreateClusterError::CloudHsmInvalidRequest(ref cause) => cause,
CreateClusterError::CloudHsmResourceNotFound(ref cause) => cause,
CreateClusterError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateHsmError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl CreateHsmError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateHsmError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(CreateHsmError::CloudHsmAccessDenied(err.msg))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(CreateHsmError::CloudHsmInternalFailure(err.msg))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(CreateHsmError::CloudHsmInvalidRequest(err.msg))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(CreateHsmError::CloudHsmResourceNotFound(err.msg))
}
"CloudHsmServiceException" => {
return RusotoError::Service(CreateHsmError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for CreateHsmError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateHsmError {
fn description(&self) -> &str {
match *self {
CreateHsmError::CloudHsmAccessDenied(ref cause) => cause,
CreateHsmError::CloudHsmInternalFailure(ref cause) => cause,
CreateHsmError::CloudHsmInvalidRequest(ref cause) => cause,
CreateHsmError::CloudHsmResourceNotFound(ref cause) => cause,
CreateHsmError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteBackupError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl DeleteBackupError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteBackupError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(DeleteBackupError::CloudHsmAccessDenied(err.msg))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(DeleteBackupError::CloudHsmInternalFailure(
err.msg,
))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(DeleteBackupError::CloudHsmInvalidRequest(err.msg))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(DeleteBackupError::CloudHsmResourceNotFound(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(DeleteBackupError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteBackupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteBackupError {
fn description(&self) -> &str {
match *self {
DeleteBackupError::CloudHsmAccessDenied(ref cause) => cause,
DeleteBackupError::CloudHsmInternalFailure(ref cause) => cause,
DeleteBackupError::CloudHsmInvalidRequest(ref cause) => cause,
DeleteBackupError::CloudHsmResourceNotFound(ref cause) => cause,
DeleteBackupError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteClusterError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl DeleteClusterError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteClusterError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(DeleteClusterError::CloudHsmAccessDenied(err.msg))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(DeleteClusterError::CloudHsmInternalFailure(
err.msg,
))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(DeleteClusterError::CloudHsmInvalidRequest(
err.msg,
))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(DeleteClusterError::CloudHsmResourceNotFound(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(DeleteClusterError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteClusterError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteClusterError {
fn description(&self) -> &str {
match *self {
DeleteClusterError::CloudHsmAccessDenied(ref cause) => cause,
DeleteClusterError::CloudHsmInternalFailure(ref cause) => cause,
DeleteClusterError::CloudHsmInvalidRequest(ref cause) => cause,
DeleteClusterError::CloudHsmResourceNotFound(ref cause) => cause,
DeleteClusterError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteHsmError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl DeleteHsmError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteHsmError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(DeleteHsmError::CloudHsmAccessDenied(err.msg))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(DeleteHsmError::CloudHsmInternalFailure(err.msg))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(DeleteHsmError::CloudHsmInvalidRequest(err.msg))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(DeleteHsmError::CloudHsmResourceNotFound(err.msg))
}
"CloudHsmServiceException" => {
return RusotoError::Service(DeleteHsmError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteHsmError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteHsmError {
fn description(&self) -> &str {
match *self {
DeleteHsmError::CloudHsmAccessDenied(ref cause) => cause,
DeleteHsmError::CloudHsmInternalFailure(ref cause) => cause,
DeleteHsmError::CloudHsmInvalidRequest(ref cause) => cause,
DeleteHsmError::CloudHsmResourceNotFound(ref cause) => cause,
DeleteHsmError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeBackupsError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl DescribeBackupsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeBackupsError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(DescribeBackupsError::CloudHsmAccessDenied(
err.msg,
))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(DescribeBackupsError::CloudHsmInternalFailure(
err.msg,
))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(DescribeBackupsError::CloudHsmInvalidRequest(
err.msg,
))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(DescribeBackupsError::CloudHsmResourceNotFound(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(DescribeBackupsError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeBackupsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeBackupsError {
fn description(&self) -> &str {
match *self {
DescribeBackupsError::CloudHsmAccessDenied(ref cause) => cause,
DescribeBackupsError::CloudHsmInternalFailure(ref cause) => cause,
DescribeBackupsError::CloudHsmInvalidRequest(ref cause) => cause,
DescribeBackupsError::CloudHsmResourceNotFound(ref cause) => cause,
DescribeBackupsError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeClustersError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmService(String),
}
impl DescribeClustersError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeClustersError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(DescribeClustersError::CloudHsmAccessDenied(
err.msg,
))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(DescribeClustersError::CloudHsmInternalFailure(
err.msg,
))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(DescribeClustersError::CloudHsmInvalidRequest(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(DescribeClustersError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeClustersError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeClustersError {
fn description(&self) -> &str {
match *self {
DescribeClustersError::CloudHsmAccessDenied(ref cause) => cause,
DescribeClustersError::CloudHsmInternalFailure(ref cause) => cause,
DescribeClustersError::CloudHsmInvalidRequest(ref cause) => cause,
DescribeClustersError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum InitializeClusterError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl InitializeClusterError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<InitializeClusterError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(InitializeClusterError::CloudHsmAccessDenied(
err.msg,
))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(InitializeClusterError::CloudHsmInternalFailure(
err.msg,
))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(InitializeClusterError::CloudHsmInvalidRequest(
err.msg,
))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(InitializeClusterError::CloudHsmResourceNotFound(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(InitializeClusterError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for InitializeClusterError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for InitializeClusterError {
fn description(&self) -> &str {
match *self {
InitializeClusterError::CloudHsmAccessDenied(ref cause) => cause,
InitializeClusterError::CloudHsmInternalFailure(ref cause) => cause,
InitializeClusterError::CloudHsmInvalidRequest(ref cause) => cause,
InitializeClusterError::CloudHsmResourceNotFound(ref cause) => cause,
InitializeClusterError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListTagsError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl ListTagsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListTagsError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(ListTagsError::CloudHsmAccessDenied(err.msg))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(ListTagsError::CloudHsmInternalFailure(err.msg))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(ListTagsError::CloudHsmInvalidRequest(err.msg))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(ListTagsError::CloudHsmResourceNotFound(err.msg))
}
"CloudHsmServiceException" => {
return RusotoError::Service(ListTagsError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListTagsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListTagsError {
fn description(&self) -> &str {
match *self {
ListTagsError::CloudHsmAccessDenied(ref cause) => cause,
ListTagsError::CloudHsmInternalFailure(ref cause) => cause,
ListTagsError::CloudHsmInvalidRequest(ref cause) => cause,
ListTagsError::CloudHsmResourceNotFound(ref cause) => cause,
ListTagsError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum RestoreBackupError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl RestoreBackupError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<RestoreBackupError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(RestoreBackupError::CloudHsmAccessDenied(err.msg))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(RestoreBackupError::CloudHsmInternalFailure(
err.msg,
))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(RestoreBackupError::CloudHsmInvalidRequest(
err.msg,
))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(RestoreBackupError::CloudHsmResourceNotFound(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(RestoreBackupError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for RestoreBackupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RestoreBackupError {
fn description(&self) -> &str {
match *self {
RestoreBackupError::CloudHsmAccessDenied(ref cause) => cause,
RestoreBackupError::CloudHsmInternalFailure(ref cause) => cause,
RestoreBackupError::CloudHsmInvalidRequest(ref cause) => cause,
RestoreBackupError::CloudHsmResourceNotFound(ref cause) => cause,
RestoreBackupError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum TagResourceError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl TagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<TagResourceError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(TagResourceError::CloudHsmAccessDenied(err.msg))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(TagResourceError::CloudHsmInternalFailure(err.msg))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(TagResourceError::CloudHsmInvalidRequest(err.msg))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(TagResourceError::CloudHsmResourceNotFound(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(TagResourceError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for TagResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for TagResourceError {
fn description(&self) -> &str {
match *self {
TagResourceError::CloudHsmAccessDenied(ref cause) => cause,
TagResourceError::CloudHsmInternalFailure(ref cause) => cause,
TagResourceError::CloudHsmInvalidRequest(ref cause) => cause,
TagResourceError::CloudHsmResourceNotFound(ref cause) => cause,
TagResourceError::CloudHsmService(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UntagResourceError {
CloudHsmAccessDenied(String),
CloudHsmInternalFailure(String),
CloudHsmInvalidRequest(String),
CloudHsmResourceNotFound(String),
CloudHsmService(String),
}
impl UntagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UntagResourceError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"CloudHsmAccessDeniedException" => {
return RusotoError::Service(UntagResourceError::CloudHsmAccessDenied(err.msg))
}
"CloudHsmInternalFailureException" => {
return RusotoError::Service(UntagResourceError::CloudHsmInternalFailure(
err.msg,
))
}
"CloudHsmInvalidRequestException" => {
return RusotoError::Service(UntagResourceError::CloudHsmInvalidRequest(
err.msg,
))
}
"CloudHsmResourceNotFoundException" => {
return RusotoError::Service(UntagResourceError::CloudHsmResourceNotFound(
err.msg,
))
}
"CloudHsmServiceException" => {
return RusotoError::Service(UntagResourceError::CloudHsmService(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UntagResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UntagResourceError {
fn description(&self) -> &str {
match *self {
UntagResourceError::CloudHsmAccessDenied(ref cause) => cause,
UntagResourceError::CloudHsmInternalFailure(ref cause) => cause,
UntagResourceError::CloudHsmInvalidRequest(ref cause) => cause,
UntagResourceError::CloudHsmResourceNotFound(ref cause) => cause,
UntagResourceError::CloudHsmService(ref cause) => cause,
}
}
}
pub trait CloudHsmv2 {
fn copy_backup_to_region(
&self,
input: CopyBackupToRegionRequest,
) -> RusotoFuture<CopyBackupToRegionResponse, CopyBackupToRegionError>;
fn create_cluster(
&self,
input: CreateClusterRequest,
) -> RusotoFuture<CreateClusterResponse, CreateClusterError>;
fn create_hsm(
&self,
input: CreateHsmRequest,
) -> RusotoFuture<CreateHsmResponse, CreateHsmError>;
fn delete_backup(
&self,
input: DeleteBackupRequest,
) -> RusotoFuture<DeleteBackupResponse, DeleteBackupError>;
fn delete_cluster(
&self,
input: DeleteClusterRequest,
) -> RusotoFuture<DeleteClusterResponse, DeleteClusterError>;
fn delete_hsm(
&self,
input: DeleteHsmRequest,
) -> RusotoFuture<DeleteHsmResponse, DeleteHsmError>;
fn describe_backups(
&self,
input: DescribeBackupsRequest,
) -> RusotoFuture<DescribeBackupsResponse, DescribeBackupsError>;
fn describe_clusters(
&self,
input: DescribeClustersRequest,
) -> RusotoFuture<DescribeClustersResponse, DescribeClustersError>;
fn initialize_cluster(
&self,
input: InitializeClusterRequest,
) -> RusotoFuture<InitializeClusterResponse, InitializeClusterError>;
fn list_tags(&self, input: ListTagsRequest) -> RusotoFuture<ListTagsResponse, ListTagsError>;
fn restore_backup(
&self,
input: RestoreBackupRequest,
) -> RusotoFuture<RestoreBackupResponse, RestoreBackupError>;
fn tag_resource(
&self,
input: TagResourceRequest,
) -> RusotoFuture<TagResourceResponse, TagResourceError>;
fn untag_resource(
&self,
input: UntagResourceRequest,
) -> RusotoFuture<UntagResourceResponse, UntagResourceError>;
}
#[derive(Clone)]
pub struct CloudHsmv2Client {
client: Client,
region: region::Region,
}
impl CloudHsmv2Client {
pub fn new(region: region::Region) -> CloudHsmv2Client {
CloudHsmv2Client {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> CloudHsmv2Client
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
CloudHsmv2Client {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl CloudHsmv2 for CloudHsmv2Client {
fn copy_backup_to_region(
&self,
input: CopyBackupToRegionRequest,
) -> RusotoFuture<CopyBackupToRegionResponse, CopyBackupToRegionError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.CopyBackupToRegion");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<CopyBackupToRegionResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CopyBackupToRegionError::from_response(response))),
)
}
})
}
fn create_cluster(
&self,
input: CreateClusterRequest,
) -> RusotoFuture<CreateClusterResponse, CreateClusterError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.CreateCluster");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<CreateClusterResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateClusterError::from_response(response))),
)
}
})
}
fn create_hsm(
&self,
input: CreateHsmRequest,
) -> RusotoFuture<CreateHsmResponse, CreateHsmError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.CreateHsm");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<CreateHsmResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateHsmError::from_response(response))),
)
}
})
}
fn delete_backup(
&self,
input: DeleteBackupRequest,
) -> RusotoFuture<DeleteBackupResponse, DeleteBackupError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.DeleteBackup");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteBackupResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteBackupError::from_response(response))),
)
}
})
}
fn delete_cluster(
&self,
input: DeleteClusterRequest,
) -> RusotoFuture<DeleteClusterResponse, DeleteClusterError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.DeleteCluster");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteClusterResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteClusterError::from_response(response))),
)
}
})
}
fn delete_hsm(
&self,
input: DeleteHsmRequest,
) -> RusotoFuture<DeleteHsmResponse, DeleteHsmError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.DeleteHsm");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteHsmResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteHsmError::from_response(response))),
)
}
})
}
fn describe_backups(
&self,
input: DescribeBackupsRequest,
) -> RusotoFuture<DescribeBackupsResponse, DescribeBackupsError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.DescribeBackups");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeBackupsResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeBackupsError::from_response(response))),
)
}
})
}
fn describe_clusters(
&self,
input: DescribeClustersRequest,
) -> RusotoFuture<DescribeClustersResponse, DescribeClustersError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.DescribeClusters");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeClustersResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeClustersError::from_response(response))),
)
}
})
}
fn initialize_cluster(
&self,
input: InitializeClusterRequest,
) -> RusotoFuture<InitializeClusterResponse, InitializeClusterError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.InitializeCluster");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<InitializeClusterResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(InitializeClusterError::from_response(response))),
)
}
})
}
fn list_tags(&self, input: ListTagsRequest) -> RusotoFuture<ListTagsResponse, ListTagsError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.ListTags");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<ListTagsResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListTagsError::from_response(response))),
)
}
})
}
fn restore_backup(
&self,
input: RestoreBackupRequest,
) -> RusotoFuture<RestoreBackupResponse, RestoreBackupError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.RestoreBackup");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<RestoreBackupResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(RestoreBackupError::from_response(response))),
)
}
})
}
fn tag_resource(
&self,
input: TagResourceRequest,
) -> RusotoFuture<TagResourceResponse, TagResourceError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.TagResource");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<TagResourceResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(TagResourceError::from_response(response))),
)
}
})
}
fn untag_resource(
&self,
input: UntagResourceRequest,
) -> RusotoFuture<UntagResourceResponse, UntagResourceError> {
let mut request = SignedRequest::new("POST", "cloudhsm", &self.region, "/");
request.set_endpoint_prefix("cloudhsmv2".to_string());
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "BaldrApiService.UntagResource");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<UntagResourceResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UntagResourceError::from_response(response))),
)
}
})
}
}