use std::error::Error;
use std::fmt;
use async_trait::async_trait;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError};
use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
use serde_json;
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct AcceptInvitationRequest {
#[serde(rename = "GraphArn")]
pub graph_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct Account {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "EmailAddress")]
pub email_address: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct CreateGraphResponse {
#[serde(rename = "GraphArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub graph_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct CreateMembersRequest {
#[serde(rename = "Accounts")]
pub accounts: Vec<Account>,
#[serde(rename = "GraphArn")]
pub graph_arn: String,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct CreateMembersResponse {
#[serde(rename = "Members")]
#[serde(skip_serializing_if = "Option::is_none")]
pub members: Option<Vec<MemberDetail>>,
#[serde(rename = "UnprocessedAccounts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unprocessed_accounts: Option<Vec<UnprocessedAccount>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DeleteGraphRequest {
#[serde(rename = "GraphArn")]
pub graph_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DeleteMembersRequest {
#[serde(rename = "AccountIds")]
pub account_ids: Vec<String>,
#[serde(rename = "GraphArn")]
pub graph_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct DeleteMembersResponse {
#[serde(rename = "AccountIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_ids: Option<Vec<String>>,
#[serde(rename = "UnprocessedAccounts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unprocessed_accounts: Option<Vec<UnprocessedAccount>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DisassociateMembershipRequest {
#[serde(rename = "GraphArn")]
pub graph_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct GetMembersRequest {
#[serde(rename = "AccountIds")]
pub account_ids: Vec<String>,
#[serde(rename = "GraphArn")]
pub graph_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct GetMembersResponse {
#[serde(rename = "MemberDetails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_details: Option<Vec<MemberDetail>>,
#[serde(rename = "UnprocessedAccounts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unprocessed_accounts: Option<Vec<UnprocessedAccount>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct Graph {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "CreatedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ListGraphsRequest {
#[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(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ListGraphsResponse {
#[serde(rename = "GraphList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub graph_list: Option<Vec<Graph>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ListInvitationsRequest {
#[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(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ListInvitationsResponse {
#[serde(rename = "Invitations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invitations: Option<Vec<MemberDetail>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ListMembersRequest {
#[serde(rename = "GraphArn")]
pub graph_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(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ListMembersResponse {
#[serde(rename = "MemberDetails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_details: Option<Vec<MemberDetail>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct MemberDetail {
#[serde(rename = "AccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_id: Option<String>,
#[serde(rename = "EmailAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub email_address: Option<String>,
#[serde(rename = "GraphArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub graph_arn: Option<String>,
#[serde(rename = "InvitedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invited_time: Option<f64>,
#[serde(rename = "MasterId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub master_id: Option<String>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "UpdatedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct RejectInvitationRequest {
#[serde(rename = "GraphArn")]
pub graph_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct UnprocessedAccount {
#[serde(rename = "AccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_id: Option<String>,
#[serde(rename = "Reason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
}
#[derive(Debug, PartialEq)]
pub enum AcceptInvitationError {
Conflict(String),
InternalServer(String),
ResourceNotFound(String),
}
impl AcceptInvitationError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<AcceptInvitationError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ConflictException" => {
return RusotoError::Service(AcceptInvitationError::Conflict(err.msg))
}
"InternalServerException" => {
return RusotoError::Service(AcceptInvitationError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(AcceptInvitationError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for AcceptInvitationError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
AcceptInvitationError::Conflict(ref cause) => write!(f, "{}", cause),
AcceptInvitationError::InternalServer(ref cause) => write!(f, "{}", cause),
AcceptInvitationError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for AcceptInvitationError {}
#[derive(Debug, PartialEq)]
pub enum CreateGraphError {
Conflict(String),
InternalServer(String),
}
impl CreateGraphError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateGraphError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ConflictException" => {
return RusotoError::Service(CreateGraphError::Conflict(err.msg))
}
"InternalServerException" => {
return RusotoError::Service(CreateGraphError::InternalServer(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for CreateGraphError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
CreateGraphError::Conflict(ref cause) => write!(f, "{}", cause),
CreateGraphError::InternalServer(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for CreateGraphError {}
#[derive(Debug, PartialEq)]
pub enum CreateMembersError {
InternalServer(String),
ResourceNotFound(String),
ServiceQuotaExceeded(String),
}
impl CreateMembersError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateMembersError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(CreateMembersError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(CreateMembersError::ResourceNotFound(err.msg))
}
"ServiceQuotaExceededException" => {
return RusotoError::Service(CreateMembersError::ServiceQuotaExceeded(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for CreateMembersError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
CreateMembersError::InternalServer(ref cause) => write!(f, "{}", cause),
CreateMembersError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
CreateMembersError::ServiceQuotaExceeded(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for CreateMembersError {}
#[derive(Debug, PartialEq)]
pub enum DeleteGraphError {
InternalServer(String),
ResourceNotFound(String),
}
impl DeleteGraphError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteGraphError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(DeleteGraphError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DeleteGraphError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for DeleteGraphError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DeleteGraphError::InternalServer(ref cause) => write!(f, "{}", cause),
DeleteGraphError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DeleteGraphError {}
#[derive(Debug, PartialEq)]
pub enum DeleteMembersError {
Conflict(String),
InternalServer(String),
ResourceNotFound(String),
}
impl DeleteMembersError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteMembersError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ConflictException" => {
return RusotoError::Service(DeleteMembersError::Conflict(err.msg))
}
"InternalServerException" => {
return RusotoError::Service(DeleteMembersError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DeleteMembersError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for DeleteMembersError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DeleteMembersError::Conflict(ref cause) => write!(f, "{}", cause),
DeleteMembersError::InternalServer(ref cause) => write!(f, "{}", cause),
DeleteMembersError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DeleteMembersError {}
#[derive(Debug, PartialEq)]
pub enum DisassociateMembershipError {
Conflict(String),
InternalServer(String),
ResourceNotFound(String),
}
impl DisassociateMembershipError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DisassociateMembershipError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ConflictException" => {
return RusotoError::Service(DisassociateMembershipError::Conflict(err.msg))
}
"InternalServerException" => {
return RusotoError::Service(DisassociateMembershipError::InternalServer(
err.msg,
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DisassociateMembershipError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for DisassociateMembershipError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DisassociateMembershipError::Conflict(ref cause) => write!(f, "{}", cause),
DisassociateMembershipError::InternalServer(ref cause) => write!(f, "{}", cause),
DisassociateMembershipError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DisassociateMembershipError {}
#[derive(Debug, PartialEq)]
pub enum GetMembersError {
InternalServer(String),
ResourceNotFound(String),
}
impl GetMembersError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetMembersError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(GetMembersError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(GetMembersError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for GetMembersError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
GetMembersError::InternalServer(ref cause) => write!(f, "{}", cause),
GetMembersError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for GetMembersError {}
#[derive(Debug, PartialEq)]
pub enum ListGraphsError {
InternalServer(String),
}
impl ListGraphsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListGraphsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(ListGraphsError::InternalServer(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for ListGraphsError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ListGraphsError::InternalServer(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for ListGraphsError {}
#[derive(Debug, PartialEq)]
pub enum ListInvitationsError {
InternalServer(String),
}
impl ListInvitationsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListInvitationsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(ListInvitationsError::InternalServer(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for ListInvitationsError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ListInvitationsError::InternalServer(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for ListInvitationsError {}
#[derive(Debug, PartialEq)]
pub enum ListMembersError {
InternalServer(String),
ResourceNotFound(String),
}
impl ListMembersError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListMembersError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(ListMembersError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(ListMembersError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for ListMembersError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ListMembersError::InternalServer(ref cause) => write!(f, "{}", cause),
ListMembersError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for ListMembersError {}
#[derive(Debug, PartialEq)]
pub enum RejectInvitationError {
Conflict(String),
InternalServer(String),
ResourceNotFound(String),
}
impl RejectInvitationError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<RejectInvitationError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ConflictException" => {
return RusotoError::Service(RejectInvitationError::Conflict(err.msg))
}
"InternalServerException" => {
return RusotoError::Service(RejectInvitationError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(RejectInvitationError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for RejectInvitationError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
RejectInvitationError::Conflict(ref cause) => write!(f, "{}", cause),
RejectInvitationError::InternalServer(ref cause) => write!(f, "{}", cause),
RejectInvitationError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for RejectInvitationError {}
#[async_trait]
pub trait Detective {
async fn accept_invitation(
&self,
input: AcceptInvitationRequest,
) -> Result<(), RusotoError<AcceptInvitationError>>;
async fn create_graph(&self) -> Result<CreateGraphResponse, RusotoError<CreateGraphError>>;
async fn create_members(
&self,
input: CreateMembersRequest,
) -> Result<CreateMembersResponse, RusotoError<CreateMembersError>>;
async fn delete_graph(
&self,
input: DeleteGraphRequest,
) -> Result<(), RusotoError<DeleteGraphError>>;
async fn delete_members(
&self,
input: DeleteMembersRequest,
) -> Result<DeleteMembersResponse, RusotoError<DeleteMembersError>>;
async fn disassociate_membership(
&self,
input: DisassociateMembershipRequest,
) -> Result<(), RusotoError<DisassociateMembershipError>>;
async fn get_members(
&self,
input: GetMembersRequest,
) -> Result<GetMembersResponse, RusotoError<GetMembersError>>;
async fn list_graphs(
&self,
input: ListGraphsRequest,
) -> Result<ListGraphsResponse, RusotoError<ListGraphsError>>;
async fn list_invitations(
&self,
input: ListInvitationsRequest,
) -> Result<ListInvitationsResponse, RusotoError<ListInvitationsError>>;
async fn list_members(
&self,
input: ListMembersRequest,
) -> Result<ListMembersResponse, RusotoError<ListMembersError>>;
async fn reject_invitation(
&self,
input: RejectInvitationRequest,
) -> Result<(), RusotoError<RejectInvitationError>>;
}
#[derive(Clone)]
pub struct DetectiveClient {
client: Client,
region: region::Region,
}
impl DetectiveClient {
pub fn new(region: region::Region) -> DetectiveClient {
DetectiveClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> DetectiveClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
D: DispatchSignedRequest + Send + Sync + 'static,
{
DetectiveClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
pub fn new_with_client(client: Client, region: region::Region) -> DetectiveClient {
DetectiveClient { client, region }
}
}
#[async_trait]
impl Detective for DetectiveClient {
async fn accept_invitation(
&self,
input: AcceptInvitationRequest,
) -> Result<(), RusotoError<AcceptInvitationError>> {
let request_uri = "/invitation";
let mut request = SignedRequest::new("PUT", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = ::std::mem::drop(response);
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(AcceptInvitationError::from_response(response))
}
}
async fn create_graph(&self) -> Result<CreateGraphResponse, RusotoError<CreateGraphError>> {
let request_uri = "/graph";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<CreateGraphResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(CreateGraphError::from_response(response))
}
}
async fn create_members(
&self,
input: CreateMembersRequest,
) -> Result<CreateMembersResponse, RusotoError<CreateMembersError>> {
let request_uri = "/graph/members";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<CreateMembersResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(CreateMembersError::from_response(response))
}
}
async fn delete_graph(
&self,
input: DeleteGraphRequest,
) -> Result<(), RusotoError<DeleteGraphError>> {
let request_uri = "/graph/removal";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = ::std::mem::drop(response);
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(DeleteGraphError::from_response(response))
}
}
async fn delete_members(
&self,
input: DeleteMembersRequest,
) -> Result<DeleteMembersResponse, RusotoError<DeleteMembersError>> {
let request_uri = "/graph/members/removal";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteMembersResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(DeleteMembersError::from_response(response))
}
}
async fn disassociate_membership(
&self,
input: DisassociateMembershipRequest,
) -> Result<(), RusotoError<DisassociateMembershipError>> {
let request_uri = "/membership/removal";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = ::std::mem::drop(response);
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(DisassociateMembershipError::from_response(response))
}
}
async fn get_members(
&self,
input: GetMembersRequest,
) -> Result<GetMembersResponse, RusotoError<GetMembersError>> {
let request_uri = "/graph/members/get";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<GetMembersResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(GetMembersError::from_response(response))
}
}
async fn list_graphs(
&self,
input: ListGraphsRequest,
) -> Result<ListGraphsResponse, RusotoError<ListGraphsError>> {
let request_uri = "/graphs/list";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListGraphsResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(ListGraphsError::from_response(response))
}
}
async fn list_invitations(
&self,
input: ListInvitationsRequest,
) -> Result<ListInvitationsResponse, RusotoError<ListInvitationsError>> {
let request_uri = "/invitations/list";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListInvitationsResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(ListInvitationsError::from_response(response))
}
}
async fn list_members(
&self,
input: ListMembersRequest,
) -> Result<ListMembersResponse, RusotoError<ListMembersError>> {
let request_uri = "/graph/members/list";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListMembersResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(ListMembersError::from_response(response))
}
}
async fn reject_invitation(
&self,
input: RejectInvitationRequest,
) -> Result<(), RusotoError<RejectInvitationError>> {
let request_uri = "/invitation/removal";
let mut request = SignedRequest::new("POST", "detective", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.detective".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = ::std::mem::drop(response);
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(RejectInvitationError::from_response(response))
}
}
}