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::param::{Params, ServiceParams};
use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
use serde_json;
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateGroupInput {
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "ResourceQuery")]
pub resource_query: ResourceQuery,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateGroupOutput {
#[serde(rename = "Group")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<Group>,
#[serde(rename = "ResourceQuery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_query: Option<ResourceQuery>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteGroupInput {
#[serde(rename = "GroupName")]
pub group_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteGroupOutput {
#[serde(rename = "Group")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<Group>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetGroupInput {
#[serde(rename = "GroupName")]
pub group_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetGroupOutput {
#[serde(rename = "Group")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<Group>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetGroupQueryInput {
#[serde(rename = "GroupName")]
pub group_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetGroupQueryOutput {
#[serde(rename = "GroupQuery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_query: Option<GroupQuery>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetTagsInput {
#[serde(rename = "Arn")]
pub arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetTagsOutput {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Group {
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "GroupArn")]
pub group_arn: String,
#[serde(rename = "Name")]
pub name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GroupFilter {
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "Values")]
pub values: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GroupIdentifier {
#[serde(rename = "GroupArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_arn: Option<String>,
#[serde(rename = "GroupName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GroupQuery {
#[serde(rename = "GroupName")]
pub group_name: String,
#[serde(rename = "ResourceQuery")]
pub resource_query: ResourceQuery,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListGroupResourcesInput {
#[serde(rename = "Filters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filters: Option<Vec<ResourceFilter>>,
#[serde(rename = "GroupName")]
pub group_name: 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 ListGroupResourcesOutput {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "QueryErrors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_errors: Option<Vec<QueryError>>,
#[serde(rename = "ResourceIdentifiers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_identifiers: Option<Vec<ResourceIdentifier>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListGroupsInput {
#[serde(rename = "Filters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filters: Option<Vec<GroupFilter>>,
#[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 ListGroupsOutput {
#[serde(rename = "GroupIdentifiers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_identifiers: Option<Vec<GroupIdentifier>>,
#[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 QueryError {
#[serde(rename = "ErrorCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ResourceFilter {
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "Values")]
pub values: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResourceIdentifier {
#[serde(rename = "ResourceArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_arn: Option<String>,
#[serde(rename = "ResourceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_type: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResourceQuery {
#[serde(rename = "Query")]
pub query: String,
#[serde(rename = "Type")]
pub type_: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct SearchResourcesInput {
#[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 = "ResourceQuery")]
pub resource_query: ResourceQuery,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SearchResourcesOutput {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "QueryErrors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub query_errors: Option<Vec<QueryError>>,
#[serde(rename = "ResourceIdentifiers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_identifiers: Option<Vec<ResourceIdentifier>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct TagInput {
#[serde(rename = "Arn")]
pub arn: String,
#[serde(rename = "Tags")]
pub tags: ::std::collections::HashMap<String, String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TagOutput {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UntagInput {
#[serde(rename = "Arn")]
pub arn: String,
#[serde(rename = "Keys")]
pub keys: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UntagOutput {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Keys")]
#[serde(skip_serializing_if = "Option::is_none")]
pub keys: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateGroupInput {
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "GroupName")]
pub group_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateGroupOutput {
#[serde(rename = "Group")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<Group>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateGroupQueryInput {
#[serde(rename = "GroupName")]
pub group_name: String,
#[serde(rename = "ResourceQuery")]
pub resource_query: ResourceQuery,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateGroupQueryOutput {
#[serde(rename = "GroupQuery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_query: Option<GroupQuery>,
}
#[derive(Debug, PartialEq)]
pub enum CreateGroupError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
TooManyRequests(String),
}
impl CreateGroupError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateGroupError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(CreateGroupError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(CreateGroupError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(CreateGroupError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(CreateGroupError::MethodNotAllowed(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(CreateGroupError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for CreateGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateGroupError {
fn description(&self) -> &str {
match *self {
CreateGroupError::BadRequest(ref cause) => cause,
CreateGroupError::Forbidden(ref cause) => cause,
CreateGroupError::InternalServerError(ref cause) => cause,
CreateGroupError::MethodNotAllowed(ref cause) => cause,
CreateGroupError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteGroupError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
NotFound(String),
TooManyRequests(String),
}
impl DeleteGroupError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteGroupError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(DeleteGroupError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(DeleteGroupError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(DeleteGroupError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(DeleteGroupError::MethodNotAllowed(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(DeleteGroupError::NotFound(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(DeleteGroupError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteGroupError {
fn description(&self) -> &str {
match *self {
DeleteGroupError::BadRequest(ref cause) => cause,
DeleteGroupError::Forbidden(ref cause) => cause,
DeleteGroupError::InternalServerError(ref cause) => cause,
DeleteGroupError::MethodNotAllowed(ref cause) => cause,
DeleteGroupError::NotFound(ref cause) => cause,
DeleteGroupError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetGroupError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
NotFound(String),
TooManyRequests(String),
}
impl GetGroupError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetGroupError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(GetGroupError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(GetGroupError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(GetGroupError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(GetGroupError::MethodNotAllowed(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(GetGroupError::NotFound(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(GetGroupError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetGroupError {
fn description(&self) -> &str {
match *self {
GetGroupError::BadRequest(ref cause) => cause,
GetGroupError::Forbidden(ref cause) => cause,
GetGroupError::InternalServerError(ref cause) => cause,
GetGroupError::MethodNotAllowed(ref cause) => cause,
GetGroupError::NotFound(ref cause) => cause,
GetGroupError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetGroupQueryError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
NotFound(String),
TooManyRequests(String),
}
impl GetGroupQueryError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetGroupQueryError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(GetGroupQueryError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(GetGroupQueryError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(GetGroupQueryError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(GetGroupQueryError::MethodNotAllowed(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(GetGroupQueryError::NotFound(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(GetGroupQueryError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetGroupQueryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetGroupQueryError {
fn description(&self) -> &str {
match *self {
GetGroupQueryError::BadRequest(ref cause) => cause,
GetGroupQueryError::Forbidden(ref cause) => cause,
GetGroupQueryError::InternalServerError(ref cause) => cause,
GetGroupQueryError::MethodNotAllowed(ref cause) => cause,
GetGroupQueryError::NotFound(ref cause) => cause,
GetGroupQueryError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetTagsError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
NotFound(String),
TooManyRequests(String),
}
impl GetTagsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetTagsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(GetTagsError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(GetTagsError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(GetTagsError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(GetTagsError::MethodNotAllowed(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(GetTagsError::NotFound(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(GetTagsError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetTagsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetTagsError {
fn description(&self) -> &str {
match *self {
GetTagsError::BadRequest(ref cause) => cause,
GetTagsError::Forbidden(ref cause) => cause,
GetTagsError::InternalServerError(ref cause) => cause,
GetTagsError::MethodNotAllowed(ref cause) => cause,
GetTagsError::NotFound(ref cause) => cause,
GetTagsError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListGroupResourcesError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
NotFound(String),
TooManyRequests(String),
Unauthorized(String),
}
impl ListGroupResourcesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListGroupResourcesError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ListGroupResourcesError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(ListGroupResourcesError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(ListGroupResourcesError::InternalServerError(
err.msg,
))
}
"MethodNotAllowedException" => {
return RusotoError::Service(ListGroupResourcesError::MethodNotAllowed(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(ListGroupResourcesError::NotFound(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(ListGroupResourcesError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(ListGroupResourcesError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListGroupResourcesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListGroupResourcesError {
fn description(&self) -> &str {
match *self {
ListGroupResourcesError::BadRequest(ref cause) => cause,
ListGroupResourcesError::Forbidden(ref cause) => cause,
ListGroupResourcesError::InternalServerError(ref cause) => cause,
ListGroupResourcesError::MethodNotAllowed(ref cause) => cause,
ListGroupResourcesError::NotFound(ref cause) => cause,
ListGroupResourcesError::TooManyRequests(ref cause) => cause,
ListGroupResourcesError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListGroupsError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
TooManyRequests(String),
}
impl ListGroupsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListGroupsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ListGroupsError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(ListGroupsError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(ListGroupsError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(ListGroupsError::MethodNotAllowed(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(ListGroupsError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListGroupsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListGroupsError {
fn description(&self) -> &str {
match *self {
ListGroupsError::BadRequest(ref cause) => cause,
ListGroupsError::Forbidden(ref cause) => cause,
ListGroupsError::InternalServerError(ref cause) => cause,
ListGroupsError::MethodNotAllowed(ref cause) => cause,
ListGroupsError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum SearchResourcesError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
TooManyRequests(String),
Unauthorized(String),
}
impl SearchResourcesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<SearchResourcesError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(SearchResourcesError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(SearchResourcesError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(SearchResourcesError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(SearchResourcesError::MethodNotAllowed(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(SearchResourcesError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(SearchResourcesError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for SearchResourcesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for SearchResourcesError {
fn description(&self) -> &str {
match *self {
SearchResourcesError::BadRequest(ref cause) => cause,
SearchResourcesError::Forbidden(ref cause) => cause,
SearchResourcesError::InternalServerError(ref cause) => cause,
SearchResourcesError::MethodNotAllowed(ref cause) => cause,
SearchResourcesError::TooManyRequests(ref cause) => cause,
SearchResourcesError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum TagError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
NotFound(String),
TooManyRequests(String),
}
impl TagError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<TagError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(TagError::BadRequest(err.msg))
}
"ForbiddenException" => return RusotoError::Service(TagError::Forbidden(err.msg)),
"InternalServerErrorException" => {
return RusotoError::Service(TagError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(TagError::MethodNotAllowed(err.msg))
}
"NotFoundException" => return RusotoError::Service(TagError::NotFound(err.msg)),
"TooManyRequestsException" => {
return RusotoError::Service(TagError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for TagError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for TagError {
fn description(&self) -> &str {
match *self {
TagError::BadRequest(ref cause) => cause,
TagError::Forbidden(ref cause) => cause,
TagError::InternalServerError(ref cause) => cause,
TagError::MethodNotAllowed(ref cause) => cause,
TagError::NotFound(ref cause) => cause,
TagError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UntagError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
NotFound(String),
TooManyRequests(String),
}
impl UntagError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UntagError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(UntagError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(UntagError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(UntagError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(UntagError::MethodNotAllowed(err.msg))
}
"NotFoundException" => return RusotoError::Service(UntagError::NotFound(err.msg)),
"TooManyRequestsException" => {
return RusotoError::Service(UntagError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UntagError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UntagError {
fn description(&self) -> &str {
match *self {
UntagError::BadRequest(ref cause) => cause,
UntagError::Forbidden(ref cause) => cause,
UntagError::InternalServerError(ref cause) => cause,
UntagError::MethodNotAllowed(ref cause) => cause,
UntagError::NotFound(ref cause) => cause,
UntagError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateGroupError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
NotFound(String),
TooManyRequests(String),
}
impl UpdateGroupError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UpdateGroupError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(UpdateGroupError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(UpdateGroupError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(UpdateGroupError::InternalServerError(err.msg))
}
"MethodNotAllowedException" => {
return RusotoError::Service(UpdateGroupError::MethodNotAllowed(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(UpdateGroupError::NotFound(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(UpdateGroupError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UpdateGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateGroupError {
fn description(&self) -> &str {
match *self {
UpdateGroupError::BadRequest(ref cause) => cause,
UpdateGroupError::Forbidden(ref cause) => cause,
UpdateGroupError::InternalServerError(ref cause) => cause,
UpdateGroupError::MethodNotAllowed(ref cause) => cause,
UpdateGroupError::NotFound(ref cause) => cause,
UpdateGroupError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateGroupQueryError {
BadRequest(String),
Forbidden(String),
InternalServerError(String),
MethodNotAllowed(String),
NotFound(String),
TooManyRequests(String),
}
impl UpdateGroupQueryError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UpdateGroupQueryError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(UpdateGroupQueryError::BadRequest(err.msg))
}
"ForbiddenException" => {
return RusotoError::Service(UpdateGroupQueryError::Forbidden(err.msg))
}
"InternalServerErrorException" => {
return RusotoError::Service(UpdateGroupQueryError::InternalServerError(
err.msg,
))
}
"MethodNotAllowedException" => {
return RusotoError::Service(UpdateGroupQueryError::MethodNotAllowed(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(UpdateGroupQueryError::NotFound(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(UpdateGroupQueryError::TooManyRequests(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UpdateGroupQueryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateGroupQueryError {
fn description(&self) -> &str {
match *self {
UpdateGroupQueryError::BadRequest(ref cause) => cause,
UpdateGroupQueryError::Forbidden(ref cause) => cause,
UpdateGroupQueryError::InternalServerError(ref cause) => cause,
UpdateGroupQueryError::MethodNotAllowed(ref cause) => cause,
UpdateGroupQueryError::NotFound(ref cause) => cause,
UpdateGroupQueryError::TooManyRequests(ref cause) => cause,
}
}
}
pub trait ResourceGroups {
fn create_group(
&self,
input: CreateGroupInput,
) -> RusotoFuture<CreateGroupOutput, CreateGroupError>;
fn delete_group(
&self,
input: DeleteGroupInput,
) -> RusotoFuture<DeleteGroupOutput, DeleteGroupError>;
fn get_group(&self, input: GetGroupInput) -> RusotoFuture<GetGroupOutput, GetGroupError>;
fn get_group_query(
&self,
input: GetGroupQueryInput,
) -> RusotoFuture<GetGroupQueryOutput, GetGroupQueryError>;
fn get_tags(&self, input: GetTagsInput) -> RusotoFuture<GetTagsOutput, GetTagsError>;
fn list_group_resources(
&self,
input: ListGroupResourcesInput,
) -> RusotoFuture<ListGroupResourcesOutput, ListGroupResourcesError>;
fn list_groups(
&self,
input: ListGroupsInput,
) -> RusotoFuture<ListGroupsOutput, ListGroupsError>;
fn search_resources(
&self,
input: SearchResourcesInput,
) -> RusotoFuture<SearchResourcesOutput, SearchResourcesError>;
fn tag(&self, input: TagInput) -> RusotoFuture<TagOutput, TagError>;
fn untag(&self, input: UntagInput) -> RusotoFuture<UntagOutput, UntagError>;
fn update_group(
&self,
input: UpdateGroupInput,
) -> RusotoFuture<UpdateGroupOutput, UpdateGroupError>;
fn update_group_query(
&self,
input: UpdateGroupQueryInput,
) -> RusotoFuture<UpdateGroupQueryOutput, UpdateGroupQueryError>;
}
#[derive(Clone)]
pub struct ResourceGroupsClient {
client: Client,
region: region::Region,
}
impl ResourceGroupsClient {
pub fn new(region: region::Region) -> ResourceGroupsClient {
ResourceGroupsClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> ResourceGroupsClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
ResourceGroupsClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl ResourceGroups for ResourceGroupsClient {
fn create_group(
&self,
input: CreateGroupInput,
) -> RusotoFuture<CreateGroupOutput, CreateGroupError> {
let request_uri = "/groups";
let mut request = SignedRequest::new("POST", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<CreateGroupOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateGroupError::from_response(response))),
)
}
})
}
fn delete_group(
&self,
input: DeleteGroupInput,
) -> RusotoFuture<DeleteGroupOutput, DeleteGroupError> {
let request_uri = format!("/groups/{group_name}", group_name = input.group_name);
let mut request =
SignedRequest::new("DELETE", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteGroupOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteGroupError::from_response(response))),
)
}
})
}
fn get_group(&self, input: GetGroupInput) -> RusotoFuture<GetGroupOutput, GetGroupError> {
let request_uri = format!("/groups/{group_name}", group_name = input.group_name);
let mut request = SignedRequest::new("GET", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<GetGroupOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetGroupError::from_response(response))),
)
}
})
}
fn get_group_query(
&self,
input: GetGroupQueryInput,
) -> RusotoFuture<GetGroupQueryOutput, GetGroupQueryError> {
let request_uri = format!("/groups/{group_name}/query", group_name = input.group_name);
let mut request = SignedRequest::new("GET", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<GetGroupQueryOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetGroupQueryError::from_response(response))),
)
}
})
}
fn get_tags(&self, input: GetTagsInput) -> RusotoFuture<GetTagsOutput, GetTagsError> {
let request_uri = format!("/resources/{arn}/tags", arn = input.arn);
let mut request = SignedRequest::new("GET", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<GetTagsOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetTagsError::from_response(response))),
)
}
})
}
fn list_group_resources(
&self,
input: ListGroupResourcesInput,
) -> RusotoFuture<ListGroupResourcesOutput, ListGroupResourcesError> {
let request_uri = format!(
"/groups/{group_name}/resource-identifiers-list",
group_name = input.group_name
);
let mut request = SignedRequest::new("POST", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut params = Params::new();
if let Some(ref x) = input.max_results {
params.put("maxResults", x);
}
if let Some(ref x) = input.next_token {
params.put("nextToken", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListGroupResourcesOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListGroupResourcesError::from_response(response))),
)
}
})
}
fn list_groups(
&self,
input: ListGroupsInput,
) -> RusotoFuture<ListGroupsOutput, ListGroupsError> {
let request_uri = "/groups-list";
let mut request = SignedRequest::new("POST", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut params = Params::new();
if let Some(ref x) = input.max_results {
params.put("maxResults", x);
}
if let Some(ref x) = input.next_token {
params.put("nextToken", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListGroupsOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListGroupsError::from_response(response))),
)
}
})
}
fn search_resources(
&self,
input: SearchResourcesInput,
) -> RusotoFuture<SearchResourcesOutput, SearchResourcesError> {
let request_uri = "/resources/search";
let mut request = SignedRequest::new("POST", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<SearchResourcesOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(SearchResourcesError::from_response(response))),
)
}
})
}
fn tag(&self, input: TagInput) -> RusotoFuture<TagOutput, TagError> {
let request_uri = format!("/resources/{arn}/tags", arn = input.arn);
let mut request = SignedRequest::new("PUT", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<TagOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(TagError::from_response(response))),
)
}
})
}
fn untag(&self, input: UntagInput) -> RusotoFuture<UntagOutput, UntagError> {
let request_uri = format!("/resources/{arn}/tags", arn = input.arn);
let mut request =
SignedRequest::new("PATCH", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<UntagOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UntagError::from_response(response))),
)
}
})
}
fn update_group(
&self,
input: UpdateGroupInput,
) -> RusotoFuture<UpdateGroupOutput, UpdateGroupError> {
let request_uri = format!("/groups/{group_name}", group_name = input.group_name);
let mut request = SignedRequest::new("PUT", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<UpdateGroupOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateGroupError::from_response(response))),
)
}
})
}
fn update_group_query(
&self,
input: UpdateGroupQueryInput,
) -> RusotoFuture<UpdateGroupQueryOutput, UpdateGroupQueryError> {
let request_uri = format!("/groups/{group_name}/query", group_name = input.group_name);
let mut request = SignedRequest::new("PUT", "resource-groups", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<UpdateGroupQueryOutput, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateGroupQueryError::from_response(response))),
)
}
})
}
}