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, Serialize)]
pub struct AssociateAdminAccountRequest {
#[serde(rename = "AdminAccount")]
pub admin_account: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ComplianceViolator {
#[serde(rename = "ResourceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_id: Option<String>,
#[serde(rename = "ResourceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_type: Option<String>,
#[serde(rename = "ViolationReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub violation_reason: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteNotificationChannelRequest {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeletePolicyRequest {
#[serde(rename = "DeleteAllPolicyResources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub delete_all_policy_resources: Option<bool>,
#[serde(rename = "PolicyId")]
pub policy_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DisassociateAdminAccountRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EvaluationResult {
#[serde(rename = "ComplianceStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_status: Option<String>,
#[serde(rename = "EvaluationLimitExceeded")]
#[serde(skip_serializing_if = "Option::is_none")]
pub evaluation_limit_exceeded: Option<bool>,
#[serde(rename = "ViolatorCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub violator_count: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetAdminAccountRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetAdminAccountResponse {
#[serde(rename = "AdminAccount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub admin_account: Option<String>,
#[serde(rename = "RoleStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetComplianceDetailRequest {
#[serde(rename = "MemberAccount")]
pub member_account: String,
#[serde(rename = "PolicyId")]
pub policy_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetComplianceDetailResponse {
#[serde(rename = "PolicyComplianceDetail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_compliance_detail: Option<PolicyComplianceDetail>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetNotificationChannelRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetNotificationChannelResponse {
#[serde(rename = "SnsRoleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sns_role_name: Option<String>,
#[serde(rename = "SnsTopicArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sns_topic_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetPolicyRequest {
#[serde(rename = "PolicyId")]
pub policy_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetPolicyResponse {
#[serde(rename = "Policy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy: Option<Policy>,
#[serde(rename = "PolicyArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetProtectionStatusRequest {
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "MemberAccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_account_id: Option<String>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "PolicyId")]
pub policy_id: String,
#[serde(rename = "StartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetProtectionStatusResponse {
#[serde(rename = "AdminAccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub admin_account_id: Option<String>,
#[serde(rename = "Data")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<String>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "ServiceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_type: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListComplianceStatusRequest {
#[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 = "PolicyId")]
pub policy_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListComplianceStatusResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "PolicyComplianceStatusList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_compliance_status_list: Option<Vec<PolicyComplianceStatus>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListMemberAccountsRequest {
#[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 ListMemberAccountsResponse {
#[serde(rename = "MemberAccounts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_accounts: Option<Vec<String>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListPoliciesRequest {
#[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 ListPoliciesResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "PolicyList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_list: Option<Vec<PolicySummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Policy {
#[serde(rename = "ExcludeMap")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exclude_map: Option<::std::collections::HashMap<String, Vec<String>>>,
#[serde(rename = "ExcludeResourceTags")]
pub exclude_resource_tags: bool,
#[serde(rename = "IncludeMap")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_map: Option<::std::collections::HashMap<String, Vec<String>>>,
#[serde(rename = "PolicyId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_id: Option<String>,
#[serde(rename = "PolicyName")]
pub policy_name: String,
#[serde(rename = "PolicyUpdateToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_update_token: Option<String>,
#[serde(rename = "RemediationEnabled")]
pub remediation_enabled: bool,
#[serde(rename = "ResourceTags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_tags: Option<Vec<ResourceTag>>,
#[serde(rename = "ResourceType")]
pub resource_type: String,
#[serde(rename = "ResourceTypeList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_type_list: Option<Vec<String>>,
#[serde(rename = "SecurityServicePolicyData")]
pub security_service_policy_data: SecurityServicePolicyData,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PolicyComplianceDetail {
#[serde(rename = "EvaluationLimitExceeded")]
#[serde(skip_serializing_if = "Option::is_none")]
pub evaluation_limit_exceeded: Option<bool>,
#[serde(rename = "ExpiredAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expired_at: Option<f64>,
#[serde(rename = "IssueInfoMap")]
#[serde(skip_serializing_if = "Option::is_none")]
pub issue_info_map: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "MemberAccount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_account: Option<String>,
#[serde(rename = "PolicyId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_id: Option<String>,
#[serde(rename = "PolicyOwner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_owner: Option<String>,
#[serde(rename = "Violators")]
#[serde(skip_serializing_if = "Option::is_none")]
pub violators: Option<Vec<ComplianceViolator>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PolicyComplianceStatus {
#[serde(rename = "EvaluationResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub evaluation_results: Option<Vec<EvaluationResult>>,
#[serde(rename = "IssueInfoMap")]
#[serde(skip_serializing_if = "Option::is_none")]
pub issue_info_map: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "LastUpdated")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_updated: Option<f64>,
#[serde(rename = "MemberAccount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_account: Option<String>,
#[serde(rename = "PolicyId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_id: Option<String>,
#[serde(rename = "PolicyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_name: Option<String>,
#[serde(rename = "PolicyOwner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_owner: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PolicySummary {
#[serde(rename = "PolicyArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_arn: Option<String>,
#[serde(rename = "PolicyId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_id: Option<String>,
#[serde(rename = "PolicyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_name: Option<String>,
#[serde(rename = "RemediationEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remediation_enabled: Option<bool>,
#[serde(rename = "ResourceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_type: Option<String>,
#[serde(rename = "SecurityServiceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_service_type: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutNotificationChannelRequest {
#[serde(rename = "SnsRoleName")]
pub sns_role_name: String,
#[serde(rename = "SnsTopicArn")]
pub sns_topic_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutPolicyRequest {
#[serde(rename = "Policy")]
pub policy: Policy,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PutPolicyResponse {
#[serde(rename = "Policy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy: Option<Policy>,
#[serde(rename = "PolicyArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResourceTag {
#[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, Deserialize)]
pub struct SecurityServicePolicyData {
#[serde(rename = "ManagedServiceData")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_service_data: Option<String>,
#[serde(rename = "Type")]
pub type_: String,
}
#[derive(Debug, PartialEq)]
pub enum AssociateAdminAccountError {
InternalError(String),
InvalidInput(String),
InvalidOperation(String),
ResourceNotFound(String),
}
impl AssociateAdminAccountError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<AssociateAdminAccountError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(AssociateAdminAccountError::InternalError(err.msg))
}
"InvalidInputException" => {
return RusotoError::Service(AssociateAdminAccountError::InvalidInput(err.msg))
}
"InvalidOperationException" => {
return RusotoError::Service(AssociateAdminAccountError::InvalidOperation(
err.msg,
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(AssociateAdminAccountError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for AssociateAdminAccountError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for AssociateAdminAccountError {
fn description(&self) -> &str {
match *self {
AssociateAdminAccountError::InternalError(ref cause) => cause,
AssociateAdminAccountError::InvalidInput(ref cause) => cause,
AssociateAdminAccountError::InvalidOperation(ref cause) => cause,
AssociateAdminAccountError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteNotificationChannelError {
InternalError(String),
InvalidOperation(String),
ResourceNotFound(String),
}
impl DeleteNotificationChannelError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteNotificationChannelError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(DeleteNotificationChannelError::InternalError(
err.msg,
))
}
"InvalidOperationException" => {
return RusotoError::Service(DeleteNotificationChannelError::InvalidOperation(
err.msg,
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DeleteNotificationChannelError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteNotificationChannelError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteNotificationChannelError {
fn description(&self) -> &str {
match *self {
DeleteNotificationChannelError::InternalError(ref cause) => cause,
DeleteNotificationChannelError::InvalidOperation(ref cause) => cause,
DeleteNotificationChannelError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeletePolicyError {
InternalError(String),
InvalidOperation(String),
ResourceNotFound(String),
}
impl DeletePolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeletePolicyError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(DeletePolicyError::InternalError(err.msg))
}
"InvalidOperationException" => {
return RusotoError::Service(DeletePolicyError::InvalidOperation(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DeletePolicyError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeletePolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeletePolicyError {
fn description(&self) -> &str {
match *self {
DeletePolicyError::InternalError(ref cause) => cause,
DeletePolicyError::InvalidOperation(ref cause) => cause,
DeletePolicyError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DisassociateAdminAccountError {
InternalError(String),
InvalidOperation(String),
ResourceNotFound(String),
}
impl DisassociateAdminAccountError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DisassociateAdminAccountError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(DisassociateAdminAccountError::InternalError(
err.msg,
))
}
"InvalidOperationException" => {
return RusotoError::Service(DisassociateAdminAccountError::InvalidOperation(
err.msg,
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DisassociateAdminAccountError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DisassociateAdminAccountError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DisassociateAdminAccountError {
fn description(&self) -> &str {
match *self {
DisassociateAdminAccountError::InternalError(ref cause) => cause,
DisassociateAdminAccountError::InvalidOperation(ref cause) => cause,
DisassociateAdminAccountError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetAdminAccountError {
InternalError(String),
InvalidOperation(String),
ResourceNotFound(String),
}
impl GetAdminAccountError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetAdminAccountError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(GetAdminAccountError::InternalError(err.msg))
}
"InvalidOperationException" => {
return RusotoError::Service(GetAdminAccountError::InvalidOperation(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(GetAdminAccountError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetAdminAccountError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetAdminAccountError {
fn description(&self) -> &str {
match *self {
GetAdminAccountError::InternalError(ref cause) => cause,
GetAdminAccountError::InvalidOperation(ref cause) => cause,
GetAdminAccountError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetComplianceDetailError {
InternalError(String),
ResourceNotFound(String),
}
impl GetComplianceDetailError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetComplianceDetailError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(GetComplianceDetailError::InternalError(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(GetComplianceDetailError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetComplianceDetailError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetComplianceDetailError {
fn description(&self) -> &str {
match *self {
GetComplianceDetailError::InternalError(ref cause) => cause,
GetComplianceDetailError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetNotificationChannelError {
InternalError(String),
InvalidOperation(String),
ResourceNotFound(String),
}
impl GetNotificationChannelError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetNotificationChannelError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(GetNotificationChannelError::InternalError(
err.msg,
))
}
"InvalidOperationException" => {
return RusotoError::Service(GetNotificationChannelError::InvalidOperation(
err.msg,
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(GetNotificationChannelError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetNotificationChannelError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetNotificationChannelError {
fn description(&self) -> &str {
match *self {
GetNotificationChannelError::InternalError(ref cause) => cause,
GetNotificationChannelError::InvalidOperation(ref cause) => cause,
GetNotificationChannelError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetPolicyError {
InternalError(String),
InvalidOperation(String),
InvalidType(String),
ResourceNotFound(String),
}
impl GetPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetPolicyError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(GetPolicyError::InternalError(err.msg))
}
"InvalidOperationException" => {
return RusotoError::Service(GetPolicyError::InvalidOperation(err.msg))
}
"InvalidTypeException" => {
return RusotoError::Service(GetPolicyError::InvalidType(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(GetPolicyError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetPolicyError {
fn description(&self) -> &str {
match *self {
GetPolicyError::InternalError(ref cause) => cause,
GetPolicyError::InvalidOperation(ref cause) => cause,
GetPolicyError::InvalidType(ref cause) => cause,
GetPolicyError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetProtectionStatusError {
InternalError(String),
InvalidInput(String),
ResourceNotFound(String),
}
impl GetProtectionStatusError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetProtectionStatusError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(GetProtectionStatusError::InternalError(err.msg))
}
"InvalidInputException" => {
return RusotoError::Service(GetProtectionStatusError::InvalidInput(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(GetProtectionStatusError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetProtectionStatusError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetProtectionStatusError {
fn description(&self) -> &str {
match *self {
GetProtectionStatusError::InternalError(ref cause) => cause,
GetProtectionStatusError::InvalidInput(ref cause) => cause,
GetProtectionStatusError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListComplianceStatusError {
InternalError(String),
ResourceNotFound(String),
}
impl ListComplianceStatusError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListComplianceStatusError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(ListComplianceStatusError::InternalError(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(ListComplianceStatusError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListComplianceStatusError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListComplianceStatusError {
fn description(&self) -> &str {
match *self {
ListComplianceStatusError::InternalError(ref cause) => cause,
ListComplianceStatusError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListMemberAccountsError {
InternalError(String),
ResourceNotFound(String),
}
impl ListMemberAccountsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListMemberAccountsError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(ListMemberAccountsError::InternalError(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(ListMemberAccountsError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListMemberAccountsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListMemberAccountsError {
fn description(&self) -> &str {
match *self {
ListMemberAccountsError::InternalError(ref cause) => cause,
ListMemberAccountsError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListPoliciesError {
InternalError(String),
InvalidOperation(String),
LimitExceeded(String),
ResourceNotFound(String),
}
impl ListPoliciesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListPoliciesError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(ListPoliciesError::InternalError(err.msg))
}
"InvalidOperationException" => {
return RusotoError::Service(ListPoliciesError::InvalidOperation(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(ListPoliciesError::LimitExceeded(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(ListPoliciesError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListPoliciesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListPoliciesError {
fn description(&self) -> &str {
match *self {
ListPoliciesError::InternalError(ref cause) => cause,
ListPoliciesError::InvalidOperation(ref cause) => cause,
ListPoliciesError::LimitExceeded(ref cause) => cause,
ListPoliciesError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutNotificationChannelError {
InternalError(String),
InvalidOperation(String),
ResourceNotFound(String),
}
impl PutNotificationChannelError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PutNotificationChannelError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(PutNotificationChannelError::InternalError(
err.msg,
))
}
"InvalidOperationException" => {
return RusotoError::Service(PutNotificationChannelError::InvalidOperation(
err.msg,
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(PutNotificationChannelError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for PutNotificationChannelError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutNotificationChannelError {
fn description(&self) -> &str {
match *self {
PutNotificationChannelError::InternalError(ref cause) => cause,
PutNotificationChannelError::InvalidOperation(ref cause) => cause,
PutNotificationChannelError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutPolicyError {
InternalError(String),
InvalidInput(String),
InvalidOperation(String),
InvalidType(String),
LimitExceeded(String),
ResourceNotFound(String),
}
impl PutPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PutPolicyError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalErrorException" => {
return RusotoError::Service(PutPolicyError::InternalError(err.msg))
}
"InvalidInputException" => {
return RusotoError::Service(PutPolicyError::InvalidInput(err.msg))
}
"InvalidOperationException" => {
return RusotoError::Service(PutPolicyError::InvalidOperation(err.msg))
}
"InvalidTypeException" => {
return RusotoError::Service(PutPolicyError::InvalidType(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(PutPolicyError::LimitExceeded(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(PutPolicyError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for PutPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutPolicyError {
fn description(&self) -> &str {
match *self {
PutPolicyError::InternalError(ref cause) => cause,
PutPolicyError::InvalidInput(ref cause) => cause,
PutPolicyError::InvalidOperation(ref cause) => cause,
PutPolicyError::InvalidType(ref cause) => cause,
PutPolicyError::LimitExceeded(ref cause) => cause,
PutPolicyError::ResourceNotFound(ref cause) => cause,
}
}
}
pub trait Fms {
fn associate_admin_account(
&self,
input: AssociateAdminAccountRequest,
) -> RusotoFuture<(), AssociateAdminAccountError>;
fn delete_notification_channel(&self) -> RusotoFuture<(), DeleteNotificationChannelError>;
fn delete_policy(&self, input: DeletePolicyRequest) -> RusotoFuture<(), DeletePolicyError>;
fn disassociate_admin_account(&self) -> RusotoFuture<(), DisassociateAdminAccountError>;
fn get_admin_account(&self) -> RusotoFuture<GetAdminAccountResponse, GetAdminAccountError>;
fn get_compliance_detail(
&self,
input: GetComplianceDetailRequest,
) -> RusotoFuture<GetComplianceDetailResponse, GetComplianceDetailError>;
fn get_notification_channel(
&self,
) -> RusotoFuture<GetNotificationChannelResponse, GetNotificationChannelError>;
fn get_policy(
&self,
input: GetPolicyRequest,
) -> RusotoFuture<GetPolicyResponse, GetPolicyError>;
fn get_protection_status(
&self,
input: GetProtectionStatusRequest,
) -> RusotoFuture<GetProtectionStatusResponse, GetProtectionStatusError>;
fn list_compliance_status(
&self,
input: ListComplianceStatusRequest,
) -> RusotoFuture<ListComplianceStatusResponse, ListComplianceStatusError>;
fn list_member_accounts(
&self,
input: ListMemberAccountsRequest,
) -> RusotoFuture<ListMemberAccountsResponse, ListMemberAccountsError>;
fn list_policies(
&self,
input: ListPoliciesRequest,
) -> RusotoFuture<ListPoliciesResponse, ListPoliciesError>;
fn put_notification_channel(
&self,
input: PutNotificationChannelRequest,
) -> RusotoFuture<(), PutNotificationChannelError>;
fn put_policy(
&self,
input: PutPolicyRequest,
) -> RusotoFuture<PutPolicyResponse, PutPolicyError>;
}
#[derive(Clone)]
pub struct FmsClient {
client: Client,
region: region::Region,
}
impl FmsClient {
pub fn new(region: region::Region) -> FmsClient {
FmsClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> FmsClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
FmsClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl Fms for FmsClient {
fn associate_admin_account(
&self,
input: AssociateAdminAccountRequest,
) -> RusotoFuture<(), AssociateAdminAccountError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.AssociateAdminAccount");
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(future::ok(::std::mem::drop(response)))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(AssociateAdminAccountError::from_response(response))
}),
)
}
})
}
fn delete_notification_channel(&self) -> RusotoFuture<(), DeleteNotificationChannelError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.DeleteNotificationChannel");
request.set_payload(Some(bytes::Bytes::from_static(b"{}")));
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(DeleteNotificationChannelError::from_response(response))
}))
}
})
}
fn delete_policy(&self, input: DeletePolicyRequest) -> RusotoFuture<(), DeletePolicyError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.DeletePolicy");
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(future::ok(::std::mem::drop(response)))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeletePolicyError::from_response(response))),
)
}
})
}
fn disassociate_admin_account(&self) -> RusotoFuture<(), DisassociateAdminAccountError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.DisassociateAdminAccount");
request.set_payload(Some(bytes::Bytes::from_static(b"{}")));
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(DisassociateAdminAccountError::from_response(response))
}))
}
})
}
fn get_admin_account(&self) -> RusotoFuture<GetAdminAccountResponse, GetAdminAccountError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.GetAdminAccount");
request.set_payload(Some(bytes::Bytes::from_static(b"{}")));
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::<GetAdminAccountResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetAdminAccountError::from_response(response))),
)
}
})
}
fn get_compliance_detail(
&self,
input: GetComplianceDetailRequest,
) -> RusotoFuture<GetComplianceDetailResponse, GetComplianceDetailError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.GetComplianceDetail");
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::<GetComplianceDetailResponse, _>()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(GetComplianceDetailError::from_response(response))
}),
)
}
})
}
fn get_notification_channel(
&self,
) -> RusotoFuture<GetNotificationChannelResponse, GetNotificationChannelError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.GetNotificationChannel");
request.set_payload(Some(bytes::Bytes::from_static(b"{}")));
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::<GetNotificationChannelResponse, _>()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(GetNotificationChannelError::from_response(response))
}),
)
}
})
}
fn get_policy(
&self,
input: GetPolicyRequest,
) -> RusotoFuture<GetPolicyResponse, GetPolicyError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.GetPolicy");
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::<GetPolicyResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetPolicyError::from_response(response))),
)
}
})
}
fn get_protection_status(
&self,
input: GetProtectionStatusRequest,
) -> RusotoFuture<GetProtectionStatusResponse, GetProtectionStatusError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.GetProtectionStatus");
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::<GetProtectionStatusResponse, _>()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(GetProtectionStatusError::from_response(response))
}),
)
}
})
}
fn list_compliance_status(
&self,
input: ListComplianceStatusRequest,
) -> RusotoFuture<ListComplianceStatusResponse, ListComplianceStatusError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.ListComplianceStatus");
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::<ListComplianceStatusResponse, _>()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(ListComplianceStatusError::from_response(response))
}),
)
}
})
}
fn list_member_accounts(
&self,
input: ListMemberAccountsRequest,
) -> RusotoFuture<ListMemberAccountsResponse, ListMemberAccountsError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.ListMemberAccounts");
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::<ListMemberAccountsResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListMemberAccountsError::from_response(response))),
)
}
})
}
fn list_policies(
&self,
input: ListPoliciesRequest,
) -> RusotoFuture<ListPoliciesResponse, ListPoliciesError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.ListPolicies");
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::<ListPoliciesResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListPoliciesError::from_response(response))),
)
}
})
}
fn put_notification_channel(
&self,
input: PutNotificationChannelRequest,
) -> RusotoFuture<(), PutNotificationChannelError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.PutNotificationChannel");
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(future::ok(::std::mem::drop(response)))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(PutNotificationChannelError::from_response(response))
}),
)
}
})
}
fn put_policy(
&self,
input: PutPolicyRequest,
) -> RusotoFuture<PutPolicyResponse, PutPolicyError> {
let mut request = SignedRequest::new("POST", "fms", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSFMS_20180101.PutPolicy");
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::<PutPolicyResponse, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(PutPolicyError::from_response(response))),
)
}
})
}
}