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, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Attributes {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ClaimDevicesByClaimCodeRequest {
#[serde(rename = "ClaimCode")]
pub claim_code: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ClaimDevicesByClaimCodeResponse {
#[serde(rename = "ClaimCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub claim_code: Option<String>,
#[serde(rename = "Total")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeDeviceRequest {
#[serde(rename = "DeviceId")]
pub device_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeDeviceResponse {
#[serde(rename = "DeviceDescription")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_description: Option<DeviceDescription>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Device {
#[serde(rename = "Attributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<Attributes>,
#[serde(rename = "DeviceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeviceDescription {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Attributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "DeviceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(rename = "Enabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
#[serde(rename = "RemainingLife")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remaining_life: Option<f64>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeviceEvent {
#[serde(rename = "Device")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device: Option<Device>,
#[serde(rename = "StdEvent")]
#[serde(skip_serializing_if = "Option::is_none")]
pub std_event: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DeviceMethod {
#[serde(rename = "DeviceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_type: Option<String>,
#[serde(rename = "MethodName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub method_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct FinalizeDeviceClaimRequest {
#[serde(rename = "DeviceId")]
pub device_id: 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 FinalizeDeviceClaimResponse {
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetDeviceMethodsRequest {
#[serde(rename = "DeviceId")]
pub device_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetDeviceMethodsResponse {
#[serde(rename = "DeviceMethods")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_methods: Option<Vec<DeviceMethod>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct InitiateDeviceClaimRequest {
#[serde(rename = "DeviceId")]
pub device_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct InitiateDeviceClaimResponse {
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct InvokeDeviceMethodRequest {
#[serde(rename = "DeviceId")]
pub device_id: String,
#[serde(rename = "DeviceMethod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_method: Option<DeviceMethod>,
#[serde(rename = "DeviceMethodParameters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_method_parameters: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct InvokeDeviceMethodResponse {
#[serde(rename = "DeviceMethodResponse")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_method_response: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListDeviceEventsRequest {
#[serde(rename = "DeviceId")]
pub device_id: String,
#[serde(rename = "FromTimeStamp")]
pub from_time_stamp: f64,
#[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 = "ToTimeStamp")]
pub to_time_stamp: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListDeviceEventsResponse {
#[serde(rename = "Events")]
#[serde(skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<DeviceEvent>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListDevicesRequest {
#[serde(rename = "DeviceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_type: Option<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 ListDevicesResponse {
#[serde(rename = "Devices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub devices: Option<Vec<DeviceDescription>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListTagsForResourceRequest {
#[serde(rename = "ResourceArn")]
pub resource_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListTagsForResourceResponse {
#[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 TagResourceRequest {
#[serde(rename = "ResourceArn")]
pub resource_arn: String,
#[serde(rename = "Tags")]
pub tags: ::std::collections::HashMap<String, String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UnclaimDeviceRequest {
#[serde(rename = "DeviceId")]
pub device_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UnclaimDeviceResponse {
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UntagResourceRequest {
#[serde(rename = "ResourceArn")]
pub resource_arn: String,
#[serde(rename = "TagKeys")]
pub tag_keys: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateDeviceStateRequest {
#[serde(rename = "DeviceId")]
pub device_id: String,
#[serde(rename = "Enabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateDeviceStateResponse {}
#[derive(Debug, PartialEq)]
pub enum ClaimDevicesByClaimCodeError {
Forbidden(String),
InternalFailure(String),
InvalidRequest(String),
}
impl ClaimDevicesByClaimCodeError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ClaimDevicesByClaimCodeError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ForbiddenException" => {
return RusotoError::Service(ClaimDevicesByClaimCodeError::Forbidden(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(ClaimDevicesByClaimCodeError::InternalFailure(
err.msg,
))
}
"InvalidRequestException" => {
return RusotoError::Service(ClaimDevicesByClaimCodeError::InvalidRequest(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ClaimDevicesByClaimCodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ClaimDevicesByClaimCodeError {
fn description(&self) -> &str {
match *self {
ClaimDevicesByClaimCodeError::Forbidden(ref cause) => cause,
ClaimDevicesByClaimCodeError::InternalFailure(ref cause) => cause,
ClaimDevicesByClaimCodeError::InvalidRequest(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeDeviceError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl DescribeDeviceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeDeviceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(DescribeDeviceError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(DescribeDeviceError::InvalidRequest(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DescribeDeviceError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeDeviceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeDeviceError {
fn description(&self) -> &str {
match *self {
DescribeDeviceError::InternalFailure(ref cause) => cause,
DescribeDeviceError::InvalidRequest(ref cause) => cause,
DescribeDeviceError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum FinalizeDeviceClaimError {
InternalFailure(String),
InvalidRequest(String),
PreconditionFailed(String),
ResourceConflict(String),
ResourceNotFound(String),
}
impl FinalizeDeviceClaimError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<FinalizeDeviceClaimError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(FinalizeDeviceClaimError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(FinalizeDeviceClaimError::InvalidRequest(err.msg))
}
"PreconditionFailedException" => {
return RusotoError::Service(FinalizeDeviceClaimError::PreconditionFailed(
err.msg,
))
}
"ResourceConflictException" => {
return RusotoError::Service(FinalizeDeviceClaimError::ResourceConflict(
err.msg,
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(FinalizeDeviceClaimError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for FinalizeDeviceClaimError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for FinalizeDeviceClaimError {
fn description(&self) -> &str {
match *self {
FinalizeDeviceClaimError::InternalFailure(ref cause) => cause,
FinalizeDeviceClaimError::InvalidRequest(ref cause) => cause,
FinalizeDeviceClaimError::PreconditionFailed(ref cause) => cause,
FinalizeDeviceClaimError::ResourceConflict(ref cause) => cause,
FinalizeDeviceClaimError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetDeviceMethodsError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl GetDeviceMethodsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetDeviceMethodsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(GetDeviceMethodsError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(GetDeviceMethodsError::InvalidRequest(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(GetDeviceMethodsError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetDeviceMethodsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetDeviceMethodsError {
fn description(&self) -> &str {
match *self {
GetDeviceMethodsError::InternalFailure(ref cause) => cause,
GetDeviceMethodsError::InvalidRequest(ref cause) => cause,
GetDeviceMethodsError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum InitiateDeviceClaimError {
InternalFailure(String),
InvalidRequest(String),
ResourceConflict(String),
ResourceNotFound(String),
}
impl InitiateDeviceClaimError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<InitiateDeviceClaimError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(InitiateDeviceClaimError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(InitiateDeviceClaimError::InvalidRequest(err.msg))
}
"ResourceConflictException" => {
return RusotoError::Service(InitiateDeviceClaimError::ResourceConflict(
err.msg,
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(InitiateDeviceClaimError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for InitiateDeviceClaimError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for InitiateDeviceClaimError {
fn description(&self) -> &str {
match *self {
InitiateDeviceClaimError::InternalFailure(ref cause) => cause,
InitiateDeviceClaimError::InvalidRequest(ref cause) => cause,
InitiateDeviceClaimError::ResourceConflict(ref cause) => cause,
InitiateDeviceClaimError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum InvokeDeviceMethodError {
InternalFailure(String),
InvalidRequest(String),
PreconditionFailed(String),
RangeNotSatisfiable(String),
ResourceConflict(String),
ResourceNotFound(String),
}
impl InvokeDeviceMethodError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<InvokeDeviceMethodError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(InvokeDeviceMethodError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(InvokeDeviceMethodError::InvalidRequest(err.msg))
}
"PreconditionFailedException" => {
return RusotoError::Service(InvokeDeviceMethodError::PreconditionFailed(
err.msg,
))
}
"RangeNotSatisfiableException" => {
return RusotoError::Service(InvokeDeviceMethodError::RangeNotSatisfiable(
err.msg,
))
}
"ResourceConflictException" => {
return RusotoError::Service(InvokeDeviceMethodError::ResourceConflict(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(InvokeDeviceMethodError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for InvokeDeviceMethodError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for InvokeDeviceMethodError {
fn description(&self) -> &str {
match *self {
InvokeDeviceMethodError::InternalFailure(ref cause) => cause,
InvokeDeviceMethodError::InvalidRequest(ref cause) => cause,
InvokeDeviceMethodError::PreconditionFailed(ref cause) => cause,
InvokeDeviceMethodError::RangeNotSatisfiable(ref cause) => cause,
InvokeDeviceMethodError::ResourceConflict(ref cause) => cause,
InvokeDeviceMethodError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListDeviceEventsError {
InternalFailure(String),
InvalidRequest(String),
RangeNotSatisfiable(String),
ResourceNotFound(String),
}
impl ListDeviceEventsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListDeviceEventsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(ListDeviceEventsError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(ListDeviceEventsError::InvalidRequest(err.msg))
}
"RangeNotSatisfiableException" => {
return RusotoError::Service(ListDeviceEventsError::RangeNotSatisfiable(
err.msg,
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(ListDeviceEventsError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListDeviceEventsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListDeviceEventsError {
fn description(&self) -> &str {
match *self {
ListDeviceEventsError::InternalFailure(ref cause) => cause,
ListDeviceEventsError::InvalidRequest(ref cause) => cause,
ListDeviceEventsError::RangeNotSatisfiable(ref cause) => cause,
ListDeviceEventsError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListDevicesError {
InternalFailure(String),
InvalidRequest(String),
RangeNotSatisfiable(String),
}
impl ListDevicesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListDevicesError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(ListDevicesError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(ListDevicesError::InvalidRequest(err.msg))
}
"RangeNotSatisfiableException" => {
return RusotoError::Service(ListDevicesError::RangeNotSatisfiable(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListDevicesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListDevicesError {
fn description(&self) -> &str {
match *self {
ListDevicesError::InternalFailure(ref cause) => cause,
ListDevicesError::InvalidRequest(ref cause) => cause,
ListDevicesError::RangeNotSatisfiable(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListTagsForResourceError {
InternalFailure(String),
ResourceNotFound(String),
}
impl ListTagsForResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListTagsForResourceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(ListTagsForResourceError::InternalFailure(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(ListTagsForResourceError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListTagsForResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListTagsForResourceError {
fn description(&self) -> &str {
match *self {
ListTagsForResourceError::InternalFailure(ref cause) => cause,
ListTagsForResourceError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum TagResourceError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl TagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<TagResourceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(TagResourceError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(TagResourceError::InvalidRequest(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(TagResourceError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for TagResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for TagResourceError {
fn description(&self) -> &str {
match *self {
TagResourceError::InternalFailure(ref cause) => cause,
TagResourceError::InvalidRequest(ref cause) => cause,
TagResourceError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UnclaimDeviceError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl UnclaimDeviceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UnclaimDeviceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(UnclaimDeviceError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(UnclaimDeviceError::InvalidRequest(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(UnclaimDeviceError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UnclaimDeviceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UnclaimDeviceError {
fn description(&self) -> &str {
match *self {
UnclaimDeviceError::InternalFailure(ref cause) => cause,
UnclaimDeviceError::InvalidRequest(ref cause) => cause,
UnclaimDeviceError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UntagResourceError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl UntagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UntagResourceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(UntagResourceError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(UntagResourceError::InvalidRequest(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(UntagResourceError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UntagResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UntagResourceError {
fn description(&self) -> &str {
match *self {
UntagResourceError::InternalFailure(ref cause) => cause,
UntagResourceError::InvalidRequest(ref cause) => cause,
UntagResourceError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateDeviceStateError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl UpdateDeviceStateError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UpdateDeviceStateError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(UpdateDeviceStateError::InternalFailure(err.msg))
}
"InvalidRequestException" => {
return RusotoError::Service(UpdateDeviceStateError::InvalidRequest(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(UpdateDeviceStateError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UpdateDeviceStateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateDeviceStateError {
fn description(&self) -> &str {
match *self {
UpdateDeviceStateError::InternalFailure(ref cause) => cause,
UpdateDeviceStateError::InvalidRequest(ref cause) => cause,
UpdateDeviceStateError::ResourceNotFound(ref cause) => cause,
}
}
}
pub trait Iot1ClickDevices {
fn claim_devices_by_claim_code(
&self,
input: ClaimDevicesByClaimCodeRequest,
) -> RusotoFuture<ClaimDevicesByClaimCodeResponse, ClaimDevicesByClaimCodeError>;
fn describe_device(
&self,
input: DescribeDeviceRequest,
) -> RusotoFuture<DescribeDeviceResponse, DescribeDeviceError>;
fn finalize_device_claim(
&self,
input: FinalizeDeviceClaimRequest,
) -> RusotoFuture<FinalizeDeviceClaimResponse, FinalizeDeviceClaimError>;
fn get_device_methods(
&self,
input: GetDeviceMethodsRequest,
) -> RusotoFuture<GetDeviceMethodsResponse, GetDeviceMethodsError>;
fn initiate_device_claim(
&self,
input: InitiateDeviceClaimRequest,
) -> RusotoFuture<InitiateDeviceClaimResponse, InitiateDeviceClaimError>;
fn invoke_device_method(
&self,
input: InvokeDeviceMethodRequest,
) -> RusotoFuture<InvokeDeviceMethodResponse, InvokeDeviceMethodError>;
fn list_device_events(
&self,
input: ListDeviceEventsRequest,
) -> RusotoFuture<ListDeviceEventsResponse, ListDeviceEventsError>;
fn list_devices(
&self,
input: ListDevicesRequest,
) -> RusotoFuture<ListDevicesResponse, ListDevicesError>;
fn list_tags_for_resource(
&self,
input: ListTagsForResourceRequest,
) -> RusotoFuture<ListTagsForResourceResponse, ListTagsForResourceError>;
fn tag_resource(&self, input: TagResourceRequest) -> RusotoFuture<(), TagResourceError>;
fn unclaim_device(
&self,
input: UnclaimDeviceRequest,
) -> RusotoFuture<UnclaimDeviceResponse, UnclaimDeviceError>;
fn untag_resource(&self, input: UntagResourceRequest) -> RusotoFuture<(), UntagResourceError>;
fn update_device_state(
&self,
input: UpdateDeviceStateRequest,
) -> RusotoFuture<UpdateDeviceStateResponse, UpdateDeviceStateError>;
}
#[derive(Clone)]
pub struct Iot1ClickDevicesClient {
client: Client,
region: region::Region,
}
impl Iot1ClickDevicesClient {
pub fn new(region: region::Region) -> Iot1ClickDevicesClient {
Iot1ClickDevicesClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> Iot1ClickDevicesClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
Iot1ClickDevicesClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl Iot1ClickDevices for Iot1ClickDevicesClient {
fn claim_devices_by_claim_code(
&self,
input: ClaimDevicesByClaimCodeRequest,
) -> RusotoFuture<ClaimDevicesByClaimCodeResponse, ClaimDevicesByClaimCodeError> {
let request_uri = format!("/claims/{claim_code}", claim_code = input.claim_code);
let mut request = SignedRequest::new("PUT", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ClaimDevicesByClaimCodeResponse, _>()?;
Ok(result)
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ClaimDevicesByClaimCodeError::from_response(response))
}))
}
})
}
fn describe_device(
&self,
input: DescribeDeviceRequest,
) -> RusotoFuture<DescribeDeviceResponse, DescribeDeviceError> {
let request_uri = format!("/devices/{device_id}", device_id = input.device_id);
let mut request = SignedRequest::new("GET", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeDeviceResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeDeviceError::from_response(response))),
)
}
})
}
fn finalize_device_claim(
&self,
input: FinalizeDeviceClaimRequest,
) -> RusotoFuture<FinalizeDeviceClaimResponse, FinalizeDeviceClaimError> {
let request_uri = format!(
"/devices/{device_id}/finalize-claim",
device_id = input.device_id
);
let mut request = SignedRequest::new("PUT", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<FinalizeDeviceClaimResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(FinalizeDeviceClaimError::from_response(response))
}),
)
}
})
}
fn get_device_methods(
&self,
input: GetDeviceMethodsRequest,
) -> RusotoFuture<GetDeviceMethodsResponse, GetDeviceMethodsError> {
let request_uri = format!("/devices/{device_id}/methods", device_id = input.device_id);
let mut request = SignedRequest::new("GET", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<GetDeviceMethodsResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetDeviceMethodsError::from_response(response))),
)
}
})
}
fn initiate_device_claim(
&self,
input: InitiateDeviceClaimRequest,
) -> RusotoFuture<InitiateDeviceClaimResponse, InitiateDeviceClaimError> {
let request_uri = format!(
"/devices/{device_id}/initiate-claim",
device_id = input.device_id
);
let mut request = SignedRequest::new("PUT", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<InitiateDeviceClaimResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(InitiateDeviceClaimError::from_response(response))
}),
)
}
})
}
fn invoke_device_method(
&self,
input: InvokeDeviceMethodRequest,
) -> RusotoFuture<InvokeDeviceMethodResponse, InvokeDeviceMethodError> {
let request_uri = format!("/devices/{device_id}/methods", device_id = input.device_id);
let mut request = SignedRequest::new("POST", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<InvokeDeviceMethodResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(InvokeDeviceMethodError::from_response(response))),
)
}
})
}
fn list_device_events(
&self,
input: ListDeviceEventsRequest,
) -> RusotoFuture<ListDeviceEventsResponse, ListDeviceEventsError> {
let request_uri = format!("/devices/{device_id}/events", device_id = input.device_id);
let mut request = SignedRequest::new("GET", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
let mut params = Params::new();
params.put("fromTimeStamp", &input.from_time_stamp);
if let Some(ref x) = input.max_results {
params.put("maxResults", x);
}
if let Some(ref x) = input.next_token {
params.put("nextToken", x);
}
params.put("toTimeStamp", &input.to_time_stamp);
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListDeviceEventsResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListDeviceEventsError::from_response(response))),
)
}
})
}
fn list_devices(
&self,
input: ListDevicesRequest,
) -> RusotoFuture<ListDevicesResponse, ListDevicesError> {
let request_uri = "/devices";
let mut request = SignedRequest::new("GET", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
let mut params = Params::new();
if let Some(ref x) = input.device_type {
params.put("deviceType", x);
}
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.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListDevicesResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListDevicesError::from_response(response))),
)
}
})
}
fn list_tags_for_resource(
&self,
input: ListTagsForResourceRequest,
) -> RusotoFuture<ListTagsForResourceResponse, ListTagsForResourceError> {
let request_uri = format!("/tags/{resource_arn}", resource_arn = input.resource_arn);
let mut request = SignedRequest::new("GET", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListTagsForResourceResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(ListTagsForResourceError::from_response(response))
}),
)
}
})
}
fn tag_resource(&self, input: TagResourceRequest) -> RusotoFuture<(), TagResourceError> {
let request_uri = format!("/tags/{resource_arn}", resource_arn = input.resource_arn);
let mut request = SignedRequest::new("POST", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = ::std::mem::drop(response);
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(TagResourceError::from_response(response))),
)
}
})
}
fn unclaim_device(
&self,
input: UnclaimDeviceRequest,
) -> RusotoFuture<UnclaimDeviceResponse, UnclaimDeviceError> {
let request_uri = format!("/devices/{device_id}/unclaim", device_id = input.device_id);
let mut request = SignedRequest::new("PUT", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<UnclaimDeviceResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UnclaimDeviceError::from_response(response))),
)
}
})
}
fn untag_resource(&self, input: UntagResourceRequest) -> RusotoFuture<(), UntagResourceError> {
let request_uri = format!("/tags/{resource_arn}", resource_arn = input.resource_arn);
let mut request = SignedRequest::new("DELETE", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
let mut params = Params::new();
for item in input.tag_keys.iter() {
params.put("tagKeys", item);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = ::std::mem::drop(response);
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UntagResourceError::from_response(response))),
)
}
})
}
fn update_device_state(
&self,
input: UpdateDeviceStateRequest,
) -> RusotoFuture<UpdateDeviceStateResponse, UpdateDeviceStateError> {
let request_uri = format!("/devices/{device_id}/state", device_id = input.device_id);
let mut request = SignedRequest::new("PUT", "iot1click", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("devices.iot1click".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<UpdateDeviceStateResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateDeviceStateError::from_response(response))),
)
}
})
}
}