use std::error::Error;
use std::fmt;
use std::io;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoFuture};
use rusoto_core::credential::{CredentialsError, ProvideAwsCredentials};
use rusoto_core::request::HttpDispatchError;
use rusoto_core::signature::SignedRequest;
use serde_json;
use serde_json::from_slice;
use serde_json::Value as SerdeJsonValue;
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ASN1Subject {
#[serde(rename = "CommonName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub common_name: Option<String>,
#[serde(rename = "Country")]
#[serde(skip_serializing_if = "Option::is_none")]
pub country: Option<String>,
#[serde(rename = "DistinguishedNameQualifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub distinguished_name_qualifier: Option<String>,
#[serde(rename = "GenerationQualifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub generation_qualifier: Option<String>,
#[serde(rename = "GivenName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<String>,
#[serde(rename = "Initials")]
#[serde(skip_serializing_if = "Option::is_none")]
pub initials: Option<String>,
#[serde(rename = "Locality")]
#[serde(skip_serializing_if = "Option::is_none")]
pub locality: Option<String>,
#[serde(rename = "Organization")]
#[serde(skip_serializing_if = "Option::is_none")]
pub organization: Option<String>,
#[serde(rename = "OrganizationalUnit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub organizational_unit: Option<String>,
#[serde(rename = "Pseudonym")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pseudonym: Option<String>,
#[serde(rename = "SerialNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub serial_number: Option<String>,
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "Surname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub surname: Option<String>,
#[serde(rename = "Title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CertificateAuthority {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "CertificateAuthorityConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate_authority_configuration: Option<CertificateAuthorityConfiguration>,
#[serde(rename = "CreatedAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<f64>,
#[serde(rename = "FailureReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failure_reason: Option<String>,
#[serde(rename = "LastStateChangeAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_state_change_at: Option<f64>,
#[serde(rename = "NotAfter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_after: Option<f64>,
#[serde(rename = "NotBefore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_before: Option<f64>,
#[serde(rename = "RestorableUntil")]
#[serde(skip_serializing_if = "Option::is_none")]
pub restorable_until: Option<f64>,
#[serde(rename = "RevocationConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revocation_configuration: Option<RevocationConfiguration>,
#[serde(rename = "Serial")]
#[serde(skip_serializing_if = "Option::is_none")]
pub serial: Option<String>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CertificateAuthorityConfiguration {
#[serde(rename = "KeyAlgorithm")]
pub key_algorithm: String,
#[serde(rename = "SigningAlgorithm")]
pub signing_algorithm: String,
#[serde(rename = "Subject")]
pub subject: ASN1Subject,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateCertificateAuthorityAuditReportRequest {
#[serde(rename = "AuditReportResponseFormat")]
pub audit_report_response_format: String,
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
#[serde(rename = "S3BucketName")]
pub s3_bucket_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateCertificateAuthorityAuditReportResponse {
#[serde(rename = "AuditReportId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub audit_report_id: Option<String>,
#[serde(rename = "S3Key")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_key: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateCertificateAuthorityRequest {
#[serde(rename = "CertificateAuthorityConfiguration")]
pub certificate_authority_configuration: CertificateAuthorityConfiguration,
#[serde(rename = "CertificateAuthorityType")]
pub certificate_authority_type: String,
#[serde(rename = "IdempotencyToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub idempotency_token: Option<String>,
#[serde(rename = "RevocationConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revocation_configuration: Option<RevocationConfiguration>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<Tag>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateCertificateAuthorityResponse {
#[serde(rename = "CertificateAuthorityArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate_authority_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CrlConfiguration {
#[serde(rename = "CustomCname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_cname: Option<String>,
#[serde(rename = "Enabled")]
pub enabled: bool,
#[serde(rename = "ExpirationInDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_in_days: Option<i64>,
#[serde(rename = "S3BucketName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_bucket_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteCertificateAuthorityRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
#[serde(rename = "PermanentDeletionTimeInDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub permanent_deletion_time_in_days: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeCertificateAuthorityAuditReportRequest {
#[serde(rename = "AuditReportId")]
pub audit_report_id: String,
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeCertificateAuthorityAuditReportResponse {
#[serde(rename = "AuditReportStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub audit_report_status: Option<String>,
#[serde(rename = "CreatedAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<f64>,
#[serde(rename = "S3BucketName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_bucket_name: Option<String>,
#[serde(rename = "S3Key")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_key: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeCertificateAuthorityRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeCertificateAuthorityResponse {
#[serde(rename = "CertificateAuthority")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate_authority: Option<CertificateAuthority>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetCertificateAuthorityCertificateRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetCertificateAuthorityCertificateResponse {
#[serde(rename = "Certificate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate: Option<String>,
#[serde(rename = "CertificateChain")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate_chain: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetCertificateAuthorityCsrRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetCertificateAuthorityCsrResponse {
#[serde(rename = "Csr")]
#[serde(skip_serializing_if = "Option::is_none")]
pub csr: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetCertificateRequest {
#[serde(rename = "CertificateArn")]
pub certificate_arn: String,
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetCertificateResponse {
#[serde(rename = "Certificate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate: Option<String>,
#[serde(rename = "CertificateChain")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate_chain: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ImportCertificateAuthorityCertificateRequest {
#[serde(rename = "Certificate")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
pub certificate: Vec<u8>,
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
#[serde(rename = "CertificateChain")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
pub certificate_chain: Vec<u8>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct IssueCertificateRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
#[serde(rename = "Csr")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
pub csr: Vec<u8>,
#[serde(rename = "IdempotencyToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub idempotency_token: Option<String>,
#[serde(rename = "SigningAlgorithm")]
pub signing_algorithm: String,
#[serde(rename = "Validity")]
pub validity: Validity,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct IssueCertificateResponse {
#[serde(rename = "CertificateArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListCertificateAuthoritiesRequest {
#[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 ListCertificateAuthoritiesResponse {
#[serde(rename = "CertificateAuthorities")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate_authorities: Option<Vec<CertificateAuthority>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListTagsRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: 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 ListTagsResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<Tag>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RestoreCertificateAuthorityRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RevocationConfiguration {
#[serde(rename = "CrlConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub crl_configuration: Option<CrlConfiguration>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RevokeCertificateRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
#[serde(rename = "CertificateSerial")]
pub certificate_serial: String,
#[serde(rename = "RevocationReason")]
pub revocation_reason: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Tag {
#[serde(rename = "Key")]
pub key: String,
#[serde(rename = "Value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct TagCertificateAuthorityRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
#[serde(rename = "Tags")]
pub tags: Vec<Tag>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UntagCertificateAuthorityRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
#[serde(rename = "Tags")]
pub tags: Vec<Tag>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateCertificateAuthorityRequest {
#[serde(rename = "CertificateAuthorityArn")]
pub certificate_authority_arn: String,
#[serde(rename = "RevocationConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revocation_configuration: Option<RevocationConfiguration>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct Validity {
#[serde(rename = "Type")]
pub type_: String,
#[serde(rename = "Value")]
pub value: i64,
}
#[derive(Debug, PartialEq)]
pub enum CreateCertificateAuthorityError {
InvalidArgs(String),
InvalidPolicy(String),
InvalidTag(String),
LimitExceeded(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateCertificateAuthorityError {
pub fn from_response(res: BufferedHttpResponse) -> CreateCertificateAuthorityError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArgsException" => {
return CreateCertificateAuthorityError::InvalidArgs(String::from(error_message));
}
"InvalidPolicyException" => {
return CreateCertificateAuthorityError::InvalidPolicy(String::from(
error_message,
));
}
"InvalidTagException" => {
return CreateCertificateAuthorityError::InvalidTag(String::from(error_message));
}
"LimitExceededException" => {
return CreateCertificateAuthorityError::LimitExceeded(String::from(
error_message,
));
}
"ValidationException" => {
return CreateCertificateAuthorityError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateCertificateAuthorityError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateCertificateAuthorityError {
fn from(err: serde_json::error::Error) -> CreateCertificateAuthorityError {
CreateCertificateAuthorityError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateCertificateAuthorityError {
fn from(err: CredentialsError) -> CreateCertificateAuthorityError {
CreateCertificateAuthorityError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateCertificateAuthorityError {
fn from(err: HttpDispatchError) -> CreateCertificateAuthorityError {
CreateCertificateAuthorityError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateCertificateAuthorityError {
fn from(err: io::Error) -> CreateCertificateAuthorityError {
CreateCertificateAuthorityError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateCertificateAuthorityError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateCertificateAuthorityError {
fn description(&self) -> &str {
match *self {
CreateCertificateAuthorityError::InvalidArgs(ref cause) => cause,
CreateCertificateAuthorityError::InvalidPolicy(ref cause) => cause,
CreateCertificateAuthorityError::InvalidTag(ref cause) => cause,
CreateCertificateAuthorityError::LimitExceeded(ref cause) => cause,
CreateCertificateAuthorityError::Validation(ref cause) => cause,
CreateCertificateAuthorityError::Credentials(ref err) => err.description(),
CreateCertificateAuthorityError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
CreateCertificateAuthorityError::ParseError(ref cause) => cause,
CreateCertificateAuthorityError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateCertificateAuthorityAuditReportError {
InvalidArgs(String),
InvalidArn(String),
InvalidState(String),
RequestFailed(String),
RequestInProgress(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateCertificateAuthorityAuditReportError {
pub fn from_response(res: BufferedHttpResponse) -> CreateCertificateAuthorityAuditReportError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArgsException" => {
return CreateCertificateAuthorityAuditReportError::InvalidArgs(String::from(
error_message,
));
}
"InvalidArnException" => {
return CreateCertificateAuthorityAuditReportError::InvalidArn(String::from(
error_message,
));
}
"InvalidStateException" => {
return CreateCertificateAuthorityAuditReportError::InvalidState(String::from(
error_message,
));
}
"RequestFailedException" => {
return CreateCertificateAuthorityAuditReportError::RequestFailed(String::from(
error_message,
));
}
"RequestInProgressException" => {
return CreateCertificateAuthorityAuditReportError::RequestInProgress(
String::from(error_message),
);
}
"ResourceNotFoundException" => {
return CreateCertificateAuthorityAuditReportError::ResourceNotFound(
String::from(error_message),
);
}
"ValidationException" => {
return CreateCertificateAuthorityAuditReportError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return CreateCertificateAuthorityAuditReportError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateCertificateAuthorityAuditReportError {
fn from(err: serde_json::error::Error) -> CreateCertificateAuthorityAuditReportError {
CreateCertificateAuthorityAuditReportError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateCertificateAuthorityAuditReportError {
fn from(err: CredentialsError) -> CreateCertificateAuthorityAuditReportError {
CreateCertificateAuthorityAuditReportError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateCertificateAuthorityAuditReportError {
fn from(err: HttpDispatchError) -> CreateCertificateAuthorityAuditReportError {
CreateCertificateAuthorityAuditReportError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateCertificateAuthorityAuditReportError {
fn from(err: io::Error) -> CreateCertificateAuthorityAuditReportError {
CreateCertificateAuthorityAuditReportError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateCertificateAuthorityAuditReportError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateCertificateAuthorityAuditReportError {
fn description(&self) -> &str {
match *self {
CreateCertificateAuthorityAuditReportError::InvalidArgs(ref cause) => cause,
CreateCertificateAuthorityAuditReportError::InvalidArn(ref cause) => cause,
CreateCertificateAuthorityAuditReportError::InvalidState(ref cause) => cause,
CreateCertificateAuthorityAuditReportError::RequestFailed(ref cause) => cause,
CreateCertificateAuthorityAuditReportError::RequestInProgress(ref cause) => cause,
CreateCertificateAuthorityAuditReportError::ResourceNotFound(ref cause) => cause,
CreateCertificateAuthorityAuditReportError::Validation(ref cause) => cause,
CreateCertificateAuthorityAuditReportError::Credentials(ref err) => err.description(),
CreateCertificateAuthorityAuditReportError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
CreateCertificateAuthorityAuditReportError::ParseError(ref cause) => cause,
CreateCertificateAuthorityAuditReportError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteCertificateAuthorityError {
ConcurrentModification(String),
InvalidArn(String),
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteCertificateAuthorityError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteCertificateAuthorityError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ConcurrentModificationException" => {
return DeleteCertificateAuthorityError::ConcurrentModification(String::from(
error_message,
));
}
"InvalidArnException" => {
return DeleteCertificateAuthorityError::InvalidArn(String::from(error_message));
}
"InvalidStateException" => {
return DeleteCertificateAuthorityError::InvalidState(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return DeleteCertificateAuthorityError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return DeleteCertificateAuthorityError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteCertificateAuthorityError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteCertificateAuthorityError {
fn from(err: serde_json::error::Error) -> DeleteCertificateAuthorityError {
DeleteCertificateAuthorityError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteCertificateAuthorityError {
fn from(err: CredentialsError) -> DeleteCertificateAuthorityError {
DeleteCertificateAuthorityError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteCertificateAuthorityError {
fn from(err: HttpDispatchError) -> DeleteCertificateAuthorityError {
DeleteCertificateAuthorityError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteCertificateAuthorityError {
fn from(err: io::Error) -> DeleteCertificateAuthorityError {
DeleteCertificateAuthorityError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteCertificateAuthorityError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteCertificateAuthorityError {
fn description(&self) -> &str {
match *self {
DeleteCertificateAuthorityError::ConcurrentModification(ref cause) => cause,
DeleteCertificateAuthorityError::InvalidArn(ref cause) => cause,
DeleteCertificateAuthorityError::InvalidState(ref cause) => cause,
DeleteCertificateAuthorityError::ResourceNotFound(ref cause) => cause,
DeleteCertificateAuthorityError::Validation(ref cause) => cause,
DeleteCertificateAuthorityError::Credentials(ref err) => err.description(),
DeleteCertificateAuthorityError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DeleteCertificateAuthorityError::ParseError(ref cause) => cause,
DeleteCertificateAuthorityError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeCertificateAuthorityError {
InvalidArn(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeCertificateAuthorityError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeCertificateAuthorityError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArnException" => {
return DescribeCertificateAuthorityError::InvalidArn(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return DescribeCertificateAuthorityError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeCertificateAuthorityError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeCertificateAuthorityError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeCertificateAuthorityError {
fn from(err: serde_json::error::Error) -> DescribeCertificateAuthorityError {
DescribeCertificateAuthorityError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeCertificateAuthorityError {
fn from(err: CredentialsError) -> DescribeCertificateAuthorityError {
DescribeCertificateAuthorityError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeCertificateAuthorityError {
fn from(err: HttpDispatchError) -> DescribeCertificateAuthorityError {
DescribeCertificateAuthorityError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeCertificateAuthorityError {
fn from(err: io::Error) -> DescribeCertificateAuthorityError {
DescribeCertificateAuthorityError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeCertificateAuthorityError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeCertificateAuthorityError {
fn description(&self) -> &str {
match *self {
DescribeCertificateAuthorityError::InvalidArn(ref cause) => cause,
DescribeCertificateAuthorityError::ResourceNotFound(ref cause) => cause,
DescribeCertificateAuthorityError::Validation(ref cause) => cause,
DescribeCertificateAuthorityError::Credentials(ref err) => err.description(),
DescribeCertificateAuthorityError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeCertificateAuthorityError::ParseError(ref cause) => cause,
DescribeCertificateAuthorityError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeCertificateAuthorityAuditReportError {
InvalidArgs(String),
InvalidArn(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeCertificateAuthorityAuditReportError {
pub fn from_response(
res: BufferedHttpResponse,
) -> DescribeCertificateAuthorityAuditReportError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArgsException" => {
return DescribeCertificateAuthorityAuditReportError::InvalidArgs(String::from(
error_message,
));
}
"InvalidArnException" => {
return DescribeCertificateAuthorityAuditReportError::InvalidArn(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return DescribeCertificateAuthorityAuditReportError::ResourceNotFound(
String::from(error_message),
);
}
"ValidationException" => {
return DescribeCertificateAuthorityAuditReportError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return DescribeCertificateAuthorityAuditReportError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeCertificateAuthorityAuditReportError {
fn from(err: serde_json::error::Error) -> DescribeCertificateAuthorityAuditReportError {
DescribeCertificateAuthorityAuditReportError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeCertificateAuthorityAuditReportError {
fn from(err: CredentialsError) -> DescribeCertificateAuthorityAuditReportError {
DescribeCertificateAuthorityAuditReportError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeCertificateAuthorityAuditReportError {
fn from(err: HttpDispatchError) -> DescribeCertificateAuthorityAuditReportError {
DescribeCertificateAuthorityAuditReportError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeCertificateAuthorityAuditReportError {
fn from(err: io::Error) -> DescribeCertificateAuthorityAuditReportError {
DescribeCertificateAuthorityAuditReportError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeCertificateAuthorityAuditReportError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeCertificateAuthorityAuditReportError {
fn description(&self) -> &str {
match *self {
DescribeCertificateAuthorityAuditReportError::InvalidArgs(ref cause) => cause,
DescribeCertificateAuthorityAuditReportError::InvalidArn(ref cause) => cause,
DescribeCertificateAuthorityAuditReportError::ResourceNotFound(ref cause) => cause,
DescribeCertificateAuthorityAuditReportError::Validation(ref cause) => cause,
DescribeCertificateAuthorityAuditReportError::Credentials(ref err) => err.description(),
DescribeCertificateAuthorityAuditReportError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeCertificateAuthorityAuditReportError::ParseError(ref cause) => cause,
DescribeCertificateAuthorityAuditReportError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetCertificateError {
InvalidArn(String),
InvalidState(String),
RequestFailed(String),
RequestInProgress(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetCertificateError {
pub fn from_response(res: BufferedHttpResponse) -> GetCertificateError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArnException" => {
return GetCertificateError::InvalidArn(String::from(error_message));
}
"InvalidStateException" => {
return GetCertificateError::InvalidState(String::from(error_message));
}
"RequestFailedException" => {
return GetCertificateError::RequestFailed(String::from(error_message));
}
"RequestInProgressException" => {
return GetCertificateError::RequestInProgress(String::from(error_message));
}
"ResourceNotFoundException" => {
return GetCertificateError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return GetCertificateError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetCertificateError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetCertificateError {
fn from(err: serde_json::error::Error) -> GetCertificateError {
GetCertificateError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetCertificateError {
fn from(err: CredentialsError) -> GetCertificateError {
GetCertificateError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetCertificateError {
fn from(err: HttpDispatchError) -> GetCertificateError {
GetCertificateError::HttpDispatch(err)
}
}
impl From<io::Error> for GetCertificateError {
fn from(err: io::Error) -> GetCertificateError {
GetCertificateError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetCertificateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetCertificateError {
fn description(&self) -> &str {
match *self {
GetCertificateError::InvalidArn(ref cause) => cause,
GetCertificateError::InvalidState(ref cause) => cause,
GetCertificateError::RequestFailed(ref cause) => cause,
GetCertificateError::RequestInProgress(ref cause) => cause,
GetCertificateError::ResourceNotFound(ref cause) => cause,
GetCertificateError::Validation(ref cause) => cause,
GetCertificateError::Credentials(ref err) => err.description(),
GetCertificateError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetCertificateError::ParseError(ref cause) => cause,
GetCertificateError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetCertificateAuthorityCertificateError {
InvalidArn(String),
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetCertificateAuthorityCertificateError {
pub fn from_response(res: BufferedHttpResponse) -> GetCertificateAuthorityCertificateError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArnException" => {
return GetCertificateAuthorityCertificateError::InvalidArn(String::from(
error_message,
));
}
"InvalidStateException" => {
return GetCertificateAuthorityCertificateError::InvalidState(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return GetCertificateAuthorityCertificateError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return GetCertificateAuthorityCertificateError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return GetCertificateAuthorityCertificateError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetCertificateAuthorityCertificateError {
fn from(err: serde_json::error::Error) -> GetCertificateAuthorityCertificateError {
GetCertificateAuthorityCertificateError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetCertificateAuthorityCertificateError {
fn from(err: CredentialsError) -> GetCertificateAuthorityCertificateError {
GetCertificateAuthorityCertificateError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetCertificateAuthorityCertificateError {
fn from(err: HttpDispatchError) -> GetCertificateAuthorityCertificateError {
GetCertificateAuthorityCertificateError::HttpDispatch(err)
}
}
impl From<io::Error> for GetCertificateAuthorityCertificateError {
fn from(err: io::Error) -> GetCertificateAuthorityCertificateError {
GetCertificateAuthorityCertificateError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetCertificateAuthorityCertificateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetCertificateAuthorityCertificateError {
fn description(&self) -> &str {
match *self {
GetCertificateAuthorityCertificateError::InvalidArn(ref cause) => cause,
GetCertificateAuthorityCertificateError::InvalidState(ref cause) => cause,
GetCertificateAuthorityCertificateError::ResourceNotFound(ref cause) => cause,
GetCertificateAuthorityCertificateError::Validation(ref cause) => cause,
GetCertificateAuthorityCertificateError::Credentials(ref err) => err.description(),
GetCertificateAuthorityCertificateError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetCertificateAuthorityCertificateError::ParseError(ref cause) => cause,
GetCertificateAuthorityCertificateError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetCertificateAuthorityCsrError {
InvalidArn(String),
InvalidState(String),
RequestFailed(String),
RequestInProgress(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetCertificateAuthorityCsrError {
pub fn from_response(res: BufferedHttpResponse) -> GetCertificateAuthorityCsrError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArnException" => {
return GetCertificateAuthorityCsrError::InvalidArn(String::from(error_message));
}
"InvalidStateException" => {
return GetCertificateAuthorityCsrError::InvalidState(String::from(
error_message,
));
}
"RequestFailedException" => {
return GetCertificateAuthorityCsrError::RequestFailed(String::from(
error_message,
));
}
"RequestInProgressException" => {
return GetCertificateAuthorityCsrError::RequestInProgress(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return GetCertificateAuthorityCsrError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return GetCertificateAuthorityCsrError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetCertificateAuthorityCsrError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetCertificateAuthorityCsrError {
fn from(err: serde_json::error::Error) -> GetCertificateAuthorityCsrError {
GetCertificateAuthorityCsrError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetCertificateAuthorityCsrError {
fn from(err: CredentialsError) -> GetCertificateAuthorityCsrError {
GetCertificateAuthorityCsrError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetCertificateAuthorityCsrError {
fn from(err: HttpDispatchError) -> GetCertificateAuthorityCsrError {
GetCertificateAuthorityCsrError::HttpDispatch(err)
}
}
impl From<io::Error> for GetCertificateAuthorityCsrError {
fn from(err: io::Error) -> GetCertificateAuthorityCsrError {
GetCertificateAuthorityCsrError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetCertificateAuthorityCsrError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetCertificateAuthorityCsrError {
fn description(&self) -> &str {
match *self {
GetCertificateAuthorityCsrError::InvalidArn(ref cause) => cause,
GetCertificateAuthorityCsrError::InvalidState(ref cause) => cause,
GetCertificateAuthorityCsrError::RequestFailed(ref cause) => cause,
GetCertificateAuthorityCsrError::RequestInProgress(ref cause) => cause,
GetCertificateAuthorityCsrError::ResourceNotFound(ref cause) => cause,
GetCertificateAuthorityCsrError::Validation(ref cause) => cause,
GetCertificateAuthorityCsrError::Credentials(ref err) => err.description(),
GetCertificateAuthorityCsrError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetCertificateAuthorityCsrError::ParseError(ref cause) => cause,
GetCertificateAuthorityCsrError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ImportCertificateAuthorityCertificateError {
CertificateMismatch(String),
ConcurrentModification(String),
InvalidArn(String),
InvalidState(String),
MalformedCertificate(String),
RequestFailed(String),
RequestInProgress(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ImportCertificateAuthorityCertificateError {
pub fn from_response(res: BufferedHttpResponse) -> ImportCertificateAuthorityCertificateError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"CertificateMismatchException" => {
return ImportCertificateAuthorityCertificateError::CertificateMismatch(
String::from(error_message),
);
}
"ConcurrentModificationException" => {
return ImportCertificateAuthorityCertificateError::ConcurrentModification(
String::from(error_message),
);
}
"InvalidArnException" => {
return ImportCertificateAuthorityCertificateError::InvalidArn(String::from(
error_message,
));
}
"InvalidStateException" => {
return ImportCertificateAuthorityCertificateError::InvalidState(String::from(
error_message,
));
}
"MalformedCertificateException" => {
return ImportCertificateAuthorityCertificateError::MalformedCertificate(
String::from(error_message),
);
}
"RequestFailedException" => {
return ImportCertificateAuthorityCertificateError::RequestFailed(String::from(
error_message,
));
}
"RequestInProgressException" => {
return ImportCertificateAuthorityCertificateError::RequestInProgress(
String::from(error_message),
);
}
"ResourceNotFoundException" => {
return ImportCertificateAuthorityCertificateError::ResourceNotFound(
String::from(error_message),
);
}
"ValidationException" => {
return ImportCertificateAuthorityCertificateError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return ImportCertificateAuthorityCertificateError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ImportCertificateAuthorityCertificateError {
fn from(err: serde_json::error::Error) -> ImportCertificateAuthorityCertificateError {
ImportCertificateAuthorityCertificateError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ImportCertificateAuthorityCertificateError {
fn from(err: CredentialsError) -> ImportCertificateAuthorityCertificateError {
ImportCertificateAuthorityCertificateError::Credentials(err)
}
}
impl From<HttpDispatchError> for ImportCertificateAuthorityCertificateError {
fn from(err: HttpDispatchError) -> ImportCertificateAuthorityCertificateError {
ImportCertificateAuthorityCertificateError::HttpDispatch(err)
}
}
impl From<io::Error> for ImportCertificateAuthorityCertificateError {
fn from(err: io::Error) -> ImportCertificateAuthorityCertificateError {
ImportCertificateAuthorityCertificateError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ImportCertificateAuthorityCertificateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ImportCertificateAuthorityCertificateError {
fn description(&self) -> &str {
match *self {
ImportCertificateAuthorityCertificateError::CertificateMismatch(ref cause) => cause,
ImportCertificateAuthorityCertificateError::ConcurrentModification(ref cause) => cause,
ImportCertificateAuthorityCertificateError::InvalidArn(ref cause) => cause,
ImportCertificateAuthorityCertificateError::InvalidState(ref cause) => cause,
ImportCertificateAuthorityCertificateError::MalformedCertificate(ref cause) => cause,
ImportCertificateAuthorityCertificateError::RequestFailed(ref cause) => cause,
ImportCertificateAuthorityCertificateError::RequestInProgress(ref cause) => cause,
ImportCertificateAuthorityCertificateError::ResourceNotFound(ref cause) => cause,
ImportCertificateAuthorityCertificateError::Validation(ref cause) => cause,
ImportCertificateAuthorityCertificateError::Credentials(ref err) => err.description(),
ImportCertificateAuthorityCertificateError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ImportCertificateAuthorityCertificateError::ParseError(ref cause) => cause,
ImportCertificateAuthorityCertificateError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum IssueCertificateError {
InvalidArgs(String),
InvalidArn(String),
InvalidState(String),
LimitExceeded(String),
MalformedCSR(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl IssueCertificateError {
pub fn from_response(res: BufferedHttpResponse) -> IssueCertificateError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArgsException" => {
return IssueCertificateError::InvalidArgs(String::from(error_message));
}
"InvalidArnException" => {
return IssueCertificateError::InvalidArn(String::from(error_message));
}
"InvalidStateException" => {
return IssueCertificateError::InvalidState(String::from(error_message));
}
"LimitExceededException" => {
return IssueCertificateError::LimitExceeded(String::from(error_message));
}
"MalformedCSRException" => {
return IssueCertificateError::MalformedCSR(String::from(error_message));
}
"ResourceNotFoundException" => {
return IssueCertificateError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return IssueCertificateError::Validation(error_message.to_string());
}
_ => {}
}
}
return IssueCertificateError::Unknown(res);
}
}
impl From<serde_json::error::Error> for IssueCertificateError {
fn from(err: serde_json::error::Error) -> IssueCertificateError {
IssueCertificateError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for IssueCertificateError {
fn from(err: CredentialsError) -> IssueCertificateError {
IssueCertificateError::Credentials(err)
}
}
impl From<HttpDispatchError> for IssueCertificateError {
fn from(err: HttpDispatchError) -> IssueCertificateError {
IssueCertificateError::HttpDispatch(err)
}
}
impl From<io::Error> for IssueCertificateError {
fn from(err: io::Error) -> IssueCertificateError {
IssueCertificateError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for IssueCertificateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for IssueCertificateError {
fn description(&self) -> &str {
match *self {
IssueCertificateError::InvalidArgs(ref cause) => cause,
IssueCertificateError::InvalidArn(ref cause) => cause,
IssueCertificateError::InvalidState(ref cause) => cause,
IssueCertificateError::LimitExceeded(ref cause) => cause,
IssueCertificateError::MalformedCSR(ref cause) => cause,
IssueCertificateError::ResourceNotFound(ref cause) => cause,
IssueCertificateError::Validation(ref cause) => cause,
IssueCertificateError::Credentials(ref err) => err.description(),
IssueCertificateError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
IssueCertificateError::ParseError(ref cause) => cause,
IssueCertificateError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListCertificateAuthoritiesError {
InvalidNextToken(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListCertificateAuthoritiesError {
pub fn from_response(res: BufferedHttpResponse) -> ListCertificateAuthoritiesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidNextTokenException" => {
return ListCertificateAuthoritiesError::InvalidNextToken(String::from(
error_message,
));
}
"ValidationException" => {
return ListCertificateAuthoritiesError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListCertificateAuthoritiesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListCertificateAuthoritiesError {
fn from(err: serde_json::error::Error) -> ListCertificateAuthoritiesError {
ListCertificateAuthoritiesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListCertificateAuthoritiesError {
fn from(err: CredentialsError) -> ListCertificateAuthoritiesError {
ListCertificateAuthoritiesError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListCertificateAuthoritiesError {
fn from(err: HttpDispatchError) -> ListCertificateAuthoritiesError {
ListCertificateAuthoritiesError::HttpDispatch(err)
}
}
impl From<io::Error> for ListCertificateAuthoritiesError {
fn from(err: io::Error) -> ListCertificateAuthoritiesError {
ListCertificateAuthoritiesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListCertificateAuthoritiesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListCertificateAuthoritiesError {
fn description(&self) -> &str {
match *self {
ListCertificateAuthoritiesError::InvalidNextToken(ref cause) => cause,
ListCertificateAuthoritiesError::Validation(ref cause) => cause,
ListCertificateAuthoritiesError::Credentials(ref err) => err.description(),
ListCertificateAuthoritiesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListCertificateAuthoritiesError::ParseError(ref cause) => cause,
ListCertificateAuthoritiesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListTagsError {
InvalidArn(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListTagsError {
pub fn from_response(res: BufferedHttpResponse) -> ListTagsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArnException" => {
return ListTagsError::InvalidArn(String::from(error_message));
}
"ResourceNotFoundException" => {
return ListTagsError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return ListTagsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListTagsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListTagsError {
fn from(err: serde_json::error::Error) -> ListTagsError {
ListTagsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListTagsError {
fn from(err: CredentialsError) -> ListTagsError {
ListTagsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListTagsError {
fn from(err: HttpDispatchError) -> ListTagsError {
ListTagsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListTagsError {
fn from(err: io::Error) -> ListTagsError {
ListTagsError::HttpDispatch(HttpDispatchError::from(err))
}
}
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::InvalidArn(ref cause) => cause,
ListTagsError::ResourceNotFound(ref cause) => cause,
ListTagsError::Validation(ref cause) => cause,
ListTagsError::Credentials(ref err) => err.description(),
ListTagsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListTagsError::ParseError(ref cause) => cause,
ListTagsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum RestoreCertificateAuthorityError {
InvalidArn(String),
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl RestoreCertificateAuthorityError {
pub fn from_response(res: BufferedHttpResponse) -> RestoreCertificateAuthorityError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArnException" => {
return RestoreCertificateAuthorityError::InvalidArn(String::from(error_message));
}
"InvalidStateException" => {
return RestoreCertificateAuthorityError::InvalidState(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return RestoreCertificateAuthorityError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return RestoreCertificateAuthorityError::Validation(error_message.to_string());
}
_ => {}
}
}
return RestoreCertificateAuthorityError::Unknown(res);
}
}
impl From<serde_json::error::Error> for RestoreCertificateAuthorityError {
fn from(err: serde_json::error::Error) -> RestoreCertificateAuthorityError {
RestoreCertificateAuthorityError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for RestoreCertificateAuthorityError {
fn from(err: CredentialsError) -> RestoreCertificateAuthorityError {
RestoreCertificateAuthorityError::Credentials(err)
}
}
impl From<HttpDispatchError> for RestoreCertificateAuthorityError {
fn from(err: HttpDispatchError) -> RestoreCertificateAuthorityError {
RestoreCertificateAuthorityError::HttpDispatch(err)
}
}
impl From<io::Error> for RestoreCertificateAuthorityError {
fn from(err: io::Error) -> RestoreCertificateAuthorityError {
RestoreCertificateAuthorityError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for RestoreCertificateAuthorityError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RestoreCertificateAuthorityError {
fn description(&self) -> &str {
match *self {
RestoreCertificateAuthorityError::InvalidArn(ref cause) => cause,
RestoreCertificateAuthorityError::InvalidState(ref cause) => cause,
RestoreCertificateAuthorityError::ResourceNotFound(ref cause) => cause,
RestoreCertificateAuthorityError::Validation(ref cause) => cause,
RestoreCertificateAuthorityError::Credentials(ref err) => err.description(),
RestoreCertificateAuthorityError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
RestoreCertificateAuthorityError::ParseError(ref cause) => cause,
RestoreCertificateAuthorityError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum RevokeCertificateError {
ConcurrentModification(String),
InvalidArn(String),
InvalidState(String),
LimitExceeded(String),
RequestAlreadyProcessed(String),
RequestFailed(String),
RequestInProgress(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl RevokeCertificateError {
pub fn from_response(res: BufferedHttpResponse) -> RevokeCertificateError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ConcurrentModificationException" => {
return RevokeCertificateError::ConcurrentModification(String::from(
error_message,
));
}
"InvalidArnException" => {
return RevokeCertificateError::InvalidArn(String::from(error_message));
}
"InvalidStateException" => {
return RevokeCertificateError::InvalidState(String::from(error_message));
}
"LimitExceededException" => {
return RevokeCertificateError::LimitExceeded(String::from(error_message));
}
"RequestAlreadyProcessedException" => {
return RevokeCertificateError::RequestAlreadyProcessed(String::from(
error_message,
));
}
"RequestFailedException" => {
return RevokeCertificateError::RequestFailed(String::from(error_message));
}
"RequestInProgressException" => {
return RevokeCertificateError::RequestInProgress(String::from(error_message));
}
"ResourceNotFoundException" => {
return RevokeCertificateError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return RevokeCertificateError::Validation(error_message.to_string());
}
_ => {}
}
}
return RevokeCertificateError::Unknown(res);
}
}
impl From<serde_json::error::Error> for RevokeCertificateError {
fn from(err: serde_json::error::Error) -> RevokeCertificateError {
RevokeCertificateError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for RevokeCertificateError {
fn from(err: CredentialsError) -> RevokeCertificateError {
RevokeCertificateError::Credentials(err)
}
}
impl From<HttpDispatchError> for RevokeCertificateError {
fn from(err: HttpDispatchError) -> RevokeCertificateError {
RevokeCertificateError::HttpDispatch(err)
}
}
impl From<io::Error> for RevokeCertificateError {
fn from(err: io::Error) -> RevokeCertificateError {
RevokeCertificateError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for RevokeCertificateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RevokeCertificateError {
fn description(&self) -> &str {
match *self {
RevokeCertificateError::ConcurrentModification(ref cause) => cause,
RevokeCertificateError::InvalidArn(ref cause) => cause,
RevokeCertificateError::InvalidState(ref cause) => cause,
RevokeCertificateError::LimitExceeded(ref cause) => cause,
RevokeCertificateError::RequestAlreadyProcessed(ref cause) => cause,
RevokeCertificateError::RequestFailed(ref cause) => cause,
RevokeCertificateError::RequestInProgress(ref cause) => cause,
RevokeCertificateError::ResourceNotFound(ref cause) => cause,
RevokeCertificateError::Validation(ref cause) => cause,
RevokeCertificateError::Credentials(ref err) => err.description(),
RevokeCertificateError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
RevokeCertificateError::ParseError(ref cause) => cause,
RevokeCertificateError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum TagCertificateAuthorityError {
InvalidArn(String),
InvalidState(String),
InvalidTag(String),
ResourceNotFound(String),
TooManyTags(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl TagCertificateAuthorityError {
pub fn from_response(res: BufferedHttpResponse) -> TagCertificateAuthorityError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArnException" => {
return TagCertificateAuthorityError::InvalidArn(String::from(error_message));
}
"InvalidStateException" => {
return TagCertificateAuthorityError::InvalidState(String::from(error_message));
}
"InvalidTagException" => {
return TagCertificateAuthorityError::InvalidTag(String::from(error_message));
}
"ResourceNotFoundException" => {
return TagCertificateAuthorityError::ResourceNotFound(String::from(
error_message,
));
}
"TooManyTagsException" => {
return TagCertificateAuthorityError::TooManyTags(String::from(error_message));
}
"ValidationException" => {
return TagCertificateAuthorityError::Validation(error_message.to_string());
}
_ => {}
}
}
return TagCertificateAuthorityError::Unknown(res);
}
}
impl From<serde_json::error::Error> for TagCertificateAuthorityError {
fn from(err: serde_json::error::Error) -> TagCertificateAuthorityError {
TagCertificateAuthorityError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for TagCertificateAuthorityError {
fn from(err: CredentialsError) -> TagCertificateAuthorityError {
TagCertificateAuthorityError::Credentials(err)
}
}
impl From<HttpDispatchError> for TagCertificateAuthorityError {
fn from(err: HttpDispatchError) -> TagCertificateAuthorityError {
TagCertificateAuthorityError::HttpDispatch(err)
}
}
impl From<io::Error> for TagCertificateAuthorityError {
fn from(err: io::Error) -> TagCertificateAuthorityError {
TagCertificateAuthorityError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for TagCertificateAuthorityError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for TagCertificateAuthorityError {
fn description(&self) -> &str {
match *self {
TagCertificateAuthorityError::InvalidArn(ref cause) => cause,
TagCertificateAuthorityError::InvalidState(ref cause) => cause,
TagCertificateAuthorityError::InvalidTag(ref cause) => cause,
TagCertificateAuthorityError::ResourceNotFound(ref cause) => cause,
TagCertificateAuthorityError::TooManyTags(ref cause) => cause,
TagCertificateAuthorityError::Validation(ref cause) => cause,
TagCertificateAuthorityError::Credentials(ref err) => err.description(),
TagCertificateAuthorityError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
TagCertificateAuthorityError::ParseError(ref cause) => cause,
TagCertificateAuthorityError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UntagCertificateAuthorityError {
InvalidArn(String),
InvalidState(String),
InvalidTag(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UntagCertificateAuthorityError {
pub fn from_response(res: BufferedHttpResponse) -> UntagCertificateAuthorityError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InvalidArnException" => {
return UntagCertificateAuthorityError::InvalidArn(String::from(error_message));
}
"InvalidStateException" => {
return UntagCertificateAuthorityError::InvalidState(String::from(error_message));
}
"InvalidTagException" => {
return UntagCertificateAuthorityError::InvalidTag(String::from(error_message));
}
"ResourceNotFoundException" => {
return UntagCertificateAuthorityError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return UntagCertificateAuthorityError::Validation(error_message.to_string());
}
_ => {}
}
}
return UntagCertificateAuthorityError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UntagCertificateAuthorityError {
fn from(err: serde_json::error::Error) -> UntagCertificateAuthorityError {
UntagCertificateAuthorityError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UntagCertificateAuthorityError {
fn from(err: CredentialsError) -> UntagCertificateAuthorityError {
UntagCertificateAuthorityError::Credentials(err)
}
}
impl From<HttpDispatchError> for UntagCertificateAuthorityError {
fn from(err: HttpDispatchError) -> UntagCertificateAuthorityError {
UntagCertificateAuthorityError::HttpDispatch(err)
}
}
impl From<io::Error> for UntagCertificateAuthorityError {
fn from(err: io::Error) -> UntagCertificateAuthorityError {
UntagCertificateAuthorityError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UntagCertificateAuthorityError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UntagCertificateAuthorityError {
fn description(&self) -> &str {
match *self {
UntagCertificateAuthorityError::InvalidArn(ref cause) => cause,
UntagCertificateAuthorityError::InvalidState(ref cause) => cause,
UntagCertificateAuthorityError::InvalidTag(ref cause) => cause,
UntagCertificateAuthorityError::ResourceNotFound(ref cause) => cause,
UntagCertificateAuthorityError::Validation(ref cause) => cause,
UntagCertificateAuthorityError::Credentials(ref err) => err.description(),
UntagCertificateAuthorityError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UntagCertificateAuthorityError::ParseError(ref cause) => cause,
UntagCertificateAuthorityError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateCertificateAuthorityError {
ConcurrentModification(String),
InvalidArgs(String),
InvalidArn(String),
InvalidPolicy(String),
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateCertificateAuthorityError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateCertificateAuthorityError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ConcurrentModificationException" => {
return UpdateCertificateAuthorityError::ConcurrentModification(String::from(
error_message,
));
}
"InvalidArgsException" => {
return UpdateCertificateAuthorityError::InvalidArgs(String::from(error_message));
}
"InvalidArnException" => {
return UpdateCertificateAuthorityError::InvalidArn(String::from(error_message));
}
"InvalidPolicyException" => {
return UpdateCertificateAuthorityError::InvalidPolicy(String::from(
error_message,
));
}
"InvalidStateException" => {
return UpdateCertificateAuthorityError::InvalidState(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return UpdateCertificateAuthorityError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return UpdateCertificateAuthorityError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateCertificateAuthorityError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateCertificateAuthorityError {
fn from(err: serde_json::error::Error) -> UpdateCertificateAuthorityError {
UpdateCertificateAuthorityError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateCertificateAuthorityError {
fn from(err: CredentialsError) -> UpdateCertificateAuthorityError {
UpdateCertificateAuthorityError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateCertificateAuthorityError {
fn from(err: HttpDispatchError) -> UpdateCertificateAuthorityError {
UpdateCertificateAuthorityError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateCertificateAuthorityError {
fn from(err: io::Error) -> UpdateCertificateAuthorityError {
UpdateCertificateAuthorityError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateCertificateAuthorityError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateCertificateAuthorityError {
fn description(&self) -> &str {
match *self {
UpdateCertificateAuthorityError::ConcurrentModification(ref cause) => cause,
UpdateCertificateAuthorityError::InvalidArgs(ref cause) => cause,
UpdateCertificateAuthorityError::InvalidArn(ref cause) => cause,
UpdateCertificateAuthorityError::InvalidPolicy(ref cause) => cause,
UpdateCertificateAuthorityError::InvalidState(ref cause) => cause,
UpdateCertificateAuthorityError::ResourceNotFound(ref cause) => cause,
UpdateCertificateAuthorityError::Validation(ref cause) => cause,
UpdateCertificateAuthorityError::Credentials(ref err) => err.description(),
UpdateCertificateAuthorityError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateCertificateAuthorityError::ParseError(ref cause) => cause,
UpdateCertificateAuthorityError::Unknown(_) => "unknown error",
}
}
}
pub trait AcmPca {
fn create_certificate_authority(
&self,
input: CreateCertificateAuthorityRequest,
) -> RusotoFuture<CreateCertificateAuthorityResponse, CreateCertificateAuthorityError>;
fn create_certificate_authority_audit_report(
&self,
input: CreateCertificateAuthorityAuditReportRequest,
) -> RusotoFuture<
CreateCertificateAuthorityAuditReportResponse,
CreateCertificateAuthorityAuditReportError,
>;
fn delete_certificate_authority(
&self,
input: DeleteCertificateAuthorityRequest,
) -> RusotoFuture<(), DeleteCertificateAuthorityError>;
fn describe_certificate_authority(
&self,
input: DescribeCertificateAuthorityRequest,
) -> RusotoFuture<DescribeCertificateAuthorityResponse, DescribeCertificateAuthorityError>;
fn describe_certificate_authority_audit_report(
&self,
input: DescribeCertificateAuthorityAuditReportRequest,
) -> RusotoFuture<
DescribeCertificateAuthorityAuditReportResponse,
DescribeCertificateAuthorityAuditReportError,
>;
fn get_certificate(
&self,
input: GetCertificateRequest,
) -> RusotoFuture<GetCertificateResponse, GetCertificateError>;
fn get_certificate_authority_certificate(
&self,
input: GetCertificateAuthorityCertificateRequest,
) -> RusotoFuture<
GetCertificateAuthorityCertificateResponse,
GetCertificateAuthorityCertificateError,
>;
fn get_certificate_authority_csr(
&self,
input: GetCertificateAuthorityCsrRequest,
) -> RusotoFuture<GetCertificateAuthorityCsrResponse, GetCertificateAuthorityCsrError>;
fn import_certificate_authority_certificate(
&self,
input: ImportCertificateAuthorityCertificateRequest,
) -> RusotoFuture<(), ImportCertificateAuthorityCertificateError>;
fn issue_certificate(
&self,
input: IssueCertificateRequest,
) -> RusotoFuture<IssueCertificateResponse, IssueCertificateError>;
fn list_certificate_authorities(
&self,
input: ListCertificateAuthoritiesRequest,
) -> RusotoFuture<ListCertificateAuthoritiesResponse, ListCertificateAuthoritiesError>;
fn list_tags(&self, input: ListTagsRequest) -> RusotoFuture<ListTagsResponse, ListTagsError>;
fn restore_certificate_authority(
&self,
input: RestoreCertificateAuthorityRequest,
) -> RusotoFuture<(), RestoreCertificateAuthorityError>;
fn revoke_certificate(
&self,
input: RevokeCertificateRequest,
) -> RusotoFuture<(), RevokeCertificateError>;
fn tag_certificate_authority(
&self,
input: TagCertificateAuthorityRequest,
) -> RusotoFuture<(), TagCertificateAuthorityError>;
fn untag_certificate_authority(
&self,
input: UntagCertificateAuthorityRequest,
) -> RusotoFuture<(), UntagCertificateAuthorityError>;
fn update_certificate_authority(
&self,
input: UpdateCertificateAuthorityRequest,
) -> RusotoFuture<(), UpdateCertificateAuthorityError>;
}
#[derive(Clone)]
pub struct AcmPcaClient {
client: Client,
region: region::Region,
}
impl AcmPcaClient {
pub fn new(region: region::Region) -> AcmPcaClient {
AcmPcaClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> AcmPcaClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
AcmPcaClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl AcmPca for AcmPcaClient {
fn create_certificate_authority(
&self,
input: CreateCertificateAuthorityRequest,
) -> RusotoFuture<CreateCertificateAuthorityResponse, CreateCertificateAuthorityError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.CreateCertificateAuthority");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<CreateCertificateAuthorityResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(CreateCertificateAuthorityError::from_response(response))
}))
}
})
}
fn create_certificate_authority_audit_report(
&self,
input: CreateCertificateAuthorityAuditReportRequest,
) -> RusotoFuture<
CreateCertificateAuthorityAuditReportResponse,
CreateCertificateAuthorityAuditReportError,
> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"ACMPrivateCA.CreateCertificateAuthorityAuditReport",
);
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<CreateCertificateAuthorityAuditReportResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(CreateCertificateAuthorityAuditReportError::from_response(
response,
))
}))
}
})
}
fn delete_certificate_authority(
&self,
input: DeleteCertificateAuthorityRequest,
) -> RusotoFuture<(), DeleteCertificateAuthorityError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.DeleteCertificateAuthority");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(future::ok(::std::mem::drop(response)))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DeleteCertificateAuthorityError::from_response(response))
}))
}
})
}
fn describe_certificate_authority(
&self,
input: DescribeCertificateAuthorityRequest,
) -> RusotoFuture<DescribeCertificateAuthorityResponse, DescribeCertificateAuthorityError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.DescribeCertificateAuthority");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DescribeCertificateAuthorityResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeCertificateAuthorityError::from_response(response))
}))
}
})
}
fn describe_certificate_authority_audit_report(
&self,
input: DescribeCertificateAuthorityAuditReportRequest,
) -> RusotoFuture<
DescribeCertificateAuthorityAuditReportResponse,
DescribeCertificateAuthorityAuditReportError,
> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"ACMPrivateCA.DescribeCertificateAuthorityAuditReport",
);
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DescribeCertificateAuthorityAuditReportResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeCertificateAuthorityAuditReportError::from_response(
response,
))
}))
}
})
}
fn get_certificate(
&self,
input: GetCertificateRequest,
) -> RusotoFuture<GetCertificateResponse, GetCertificateError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.GetCertificate");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetCertificateResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetCertificateError::from_response(response))),
)
}
})
}
fn get_certificate_authority_certificate(
&self,
input: GetCertificateAuthorityCertificateRequest,
) -> RusotoFuture<
GetCertificateAuthorityCertificateResponse,
GetCertificateAuthorityCertificateError,
> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"ACMPrivateCA.GetCertificateAuthorityCertificate",
);
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetCertificateAuthorityCertificateResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(GetCertificateAuthorityCertificateError::from_response(
response,
))
}))
}
})
}
fn get_certificate_authority_csr(
&self,
input: GetCertificateAuthorityCsrRequest,
) -> RusotoFuture<GetCertificateAuthorityCsrResponse, GetCertificateAuthorityCsrError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.GetCertificateAuthorityCsr");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetCertificateAuthorityCsrResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(GetCertificateAuthorityCsrError::from_response(response))
}))
}
})
}
fn import_certificate_authority_certificate(
&self,
input: ImportCertificateAuthorityCertificateRequest,
) -> RusotoFuture<(), ImportCertificateAuthorityCertificateError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"ACMPrivateCA.ImportCertificateAuthorityCertificate",
);
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(future::ok(::std::mem::drop(response)))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ImportCertificateAuthorityCertificateError::from_response(
response,
))
}))
}
})
}
fn issue_certificate(
&self,
input: IssueCertificateRequest,
) -> RusotoFuture<IssueCertificateResponse, IssueCertificateError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.IssueCertificate");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<IssueCertificateResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(IssueCertificateError::from_response(response))),
)
}
})
}
fn list_certificate_authorities(
&self,
input: ListCertificateAuthoritiesRequest,
) -> RusotoFuture<ListCertificateAuthoritiesResponse, ListCertificateAuthoritiesError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.ListCertificateAuthorities");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<ListCertificateAuthoritiesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ListCertificateAuthoritiesError::from_response(response))
}))
}
})
}
fn list_tags(&self, input: ListTagsRequest) -> RusotoFuture<ListTagsResponse, ListTagsError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.ListTags");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<ListTagsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListTagsError::from_response(response))),
)
}
})
}
fn restore_certificate_authority(
&self,
input: RestoreCertificateAuthorityRequest,
) -> RusotoFuture<(), RestoreCertificateAuthorityError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.RestoreCertificateAuthority");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(future::ok(::std::mem::drop(response)))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(RestoreCertificateAuthorityError::from_response(response))
}))
}
})
}
fn revoke_certificate(
&self,
input: RevokeCertificateRequest,
) -> RusotoFuture<(), RevokeCertificateError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.RevokeCertificate");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(future::ok(::std::mem::drop(response)))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(RevokeCertificateError::from_response(response))),
)
}
})
}
fn tag_certificate_authority(
&self,
input: TagCertificateAuthorityRequest,
) -> RusotoFuture<(), TagCertificateAuthorityError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.TagCertificateAuthority");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(future::ok(::std::mem::drop(response)))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(TagCertificateAuthorityError::from_response(response))
}))
}
})
}
fn untag_certificate_authority(
&self,
input: UntagCertificateAuthorityRequest,
) -> RusotoFuture<(), UntagCertificateAuthorityError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.UntagCertificateAuthority");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(future::ok(::std::mem::drop(response)))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(UntagCertificateAuthorityError::from_response(response))
}))
}
})
}
fn update_certificate_authority(
&self,
input: UpdateCertificateAuthorityRequest,
) -> RusotoFuture<(), UpdateCertificateAuthorityError> {
let mut request = SignedRequest::new("POST", "acm-pca", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "ACMPrivateCA.UpdateCertificateAuthority");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(future::ok(::std::mem::drop(response)))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(UpdateCertificateAuthorityError::from_response(response))
}))
}
})
}
}
#[cfg(test)]
mod protocol_tests {}