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::signature::SignedRequest;
use serde_json;
use serde_json::from_slice;
use serde_json::Value as SerdeJsonValue;
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct AssociateDeviceWithPlacementRequest {
#[serde(rename = "deviceId")]
pub device_id: String,
#[serde(rename = "deviceTemplateName")]
pub device_template_name: String,
#[serde(rename = "placementName")]
pub placement_name: String,
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AssociateDeviceWithPlacementResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreatePlacementRequest {
#[serde(rename = "attributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "placementName")]
pub placement_name: String,
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreatePlacementResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateProjectRequest {
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "placementTemplate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub placement_template: Option<PlacementTemplate>,
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateProjectResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeletePlacementRequest {
#[serde(rename = "placementName")]
pub placement_name: String,
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeletePlacementResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteProjectRequest {
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteProjectResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribePlacementRequest {
#[serde(rename = "placementName")]
pub placement_name: String,
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribePlacementResponse {
#[serde(rename = "placement")]
pub placement: PlacementDescription,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeProjectRequest {
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeProjectResponse {
#[serde(rename = "project")]
pub project: ProjectDescription,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DeviceTemplate {
#[serde(rename = "callbackOverrides")]
#[serde(skip_serializing_if = "Option::is_none")]
pub callback_overrides: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "deviceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_type: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DisassociateDeviceFromPlacementRequest {
#[serde(rename = "deviceTemplateName")]
pub device_template_name: String,
#[serde(rename = "placementName")]
pub placement_name: String,
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DisassociateDeviceFromPlacementResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetDevicesInPlacementRequest {
#[serde(rename = "placementName")]
pub placement_name: String,
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetDevicesInPlacementResponse {
#[serde(rename = "devices")]
pub devices: ::std::collections::HashMap<String, String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListPlacementsRequest {
#[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 = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListPlacementsResponse {
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "placements")]
pub placements: Vec<PlacementSummary>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListProjectsRequest {
#[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 ListProjectsResponse {
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "projects")]
pub projects: Vec<ProjectSummary>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PlacementDescription {
#[serde(rename = "attributes")]
pub attributes: ::std::collections::HashMap<String, String>,
#[serde(rename = "createdDate")]
pub created_date: f64,
#[serde(rename = "placementName")]
pub placement_name: String,
#[serde(rename = "projectName")]
pub project_name: String,
#[serde(rename = "updatedDate")]
pub updated_date: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PlacementSummary {
#[serde(rename = "createdDate")]
pub created_date: f64,
#[serde(rename = "placementName")]
pub placement_name: String,
#[serde(rename = "projectName")]
pub project_name: String,
#[serde(rename = "updatedDate")]
pub updated_date: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PlacementTemplate {
#[serde(rename = "defaultAttributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub default_attributes: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "deviceTemplates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_templates: Option<::std::collections::HashMap<String, DeviceTemplate>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ProjectDescription {
#[serde(rename = "createdDate")]
pub created_date: f64,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "placementTemplate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub placement_template: Option<PlacementTemplate>,
#[serde(rename = "projectName")]
pub project_name: String,
#[serde(rename = "updatedDate")]
pub updated_date: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ProjectSummary {
#[serde(rename = "createdDate")]
pub created_date: f64,
#[serde(rename = "projectName")]
pub project_name: String,
#[serde(rename = "updatedDate")]
pub updated_date: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdatePlacementRequest {
#[serde(rename = "attributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "placementName")]
pub placement_name: String,
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdatePlacementResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateProjectRequest {
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "placementTemplate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub placement_template: Option<PlacementTemplate>,
#[serde(rename = "projectName")]
pub project_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateProjectResponse {}
#[derive(Debug, PartialEq)]
pub enum AssociateDeviceWithPlacementError {
InternalFailure(String),
InvalidRequest(String),
ResourceConflict(String),
ResourceNotFound(String),
}
impl AssociateDeviceWithPlacementError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<AssociateDeviceWithPlacementError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(
AssociateDeviceWithPlacementError::InternalFailure(String::from(
error_message,
)),
)
}
"InvalidRequestException" => {
return RusotoError::Service(AssociateDeviceWithPlacementError::InvalidRequest(
String::from(error_message),
))
}
"ResourceConflictException" => {
return RusotoError::Service(
AssociateDeviceWithPlacementError::ResourceConflict(String::from(
error_message,
)),
)
}
"ResourceNotFoundException" => {
return RusotoError::Service(
AssociateDeviceWithPlacementError::ResourceNotFound(String::from(
error_message,
)),
)
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for AssociateDeviceWithPlacementError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for AssociateDeviceWithPlacementError {
fn description(&self) -> &str {
match *self {
AssociateDeviceWithPlacementError::InternalFailure(ref cause) => cause,
AssociateDeviceWithPlacementError::InvalidRequest(ref cause) => cause,
AssociateDeviceWithPlacementError::ResourceConflict(ref cause) => cause,
AssociateDeviceWithPlacementError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreatePlacementError {
InternalFailure(String),
InvalidRequest(String),
ResourceConflict(String),
ResourceNotFound(String),
}
impl CreatePlacementError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreatePlacementError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(CreatePlacementError::InternalFailure(
String::from(error_message),
))
}
"InvalidRequestException" => {
return RusotoError::Service(CreatePlacementError::InvalidRequest(
String::from(error_message),
))
}
"ResourceConflictException" => {
return RusotoError::Service(CreatePlacementError::ResourceConflict(
String::from(error_message),
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(CreatePlacementError::ResourceNotFound(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for CreatePlacementError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreatePlacementError {
fn description(&self) -> &str {
match *self {
CreatePlacementError::InternalFailure(ref cause) => cause,
CreatePlacementError::InvalidRequest(ref cause) => cause,
CreatePlacementError::ResourceConflict(ref cause) => cause,
CreatePlacementError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateProjectError {
InternalFailure(String),
InvalidRequest(String),
ResourceConflict(String),
}
impl CreateProjectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateProjectError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(CreateProjectError::InternalFailure(String::from(
error_message,
)))
}
"InvalidRequestException" => {
return RusotoError::Service(CreateProjectError::InvalidRequest(String::from(
error_message,
)))
}
"ResourceConflictException" => {
return RusotoError::Service(CreateProjectError::ResourceConflict(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for CreateProjectError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateProjectError {
fn description(&self) -> &str {
match *self {
CreateProjectError::InternalFailure(ref cause) => cause,
CreateProjectError::InvalidRequest(ref cause) => cause,
CreateProjectError::ResourceConflict(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeletePlacementError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
TooManyRequests(String),
}
impl DeletePlacementError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeletePlacementError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(DeletePlacementError::InternalFailure(
String::from(error_message),
))
}
"InvalidRequestException" => {
return RusotoError::Service(DeletePlacementError::InvalidRequest(
String::from(error_message),
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DeletePlacementError::ResourceNotFound(
String::from(error_message),
))
}
"TooManyRequestsException" => {
return RusotoError::Service(DeletePlacementError::TooManyRequests(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeletePlacementError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeletePlacementError {
fn description(&self) -> &str {
match *self {
DeletePlacementError::InternalFailure(ref cause) => cause,
DeletePlacementError::InvalidRequest(ref cause) => cause,
DeletePlacementError::ResourceNotFound(ref cause) => cause,
DeletePlacementError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteProjectError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
TooManyRequests(String),
}
impl DeleteProjectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteProjectError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(DeleteProjectError::InternalFailure(String::from(
error_message,
)))
}
"InvalidRequestException" => {
return RusotoError::Service(DeleteProjectError::InvalidRequest(String::from(
error_message,
)))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DeleteProjectError::ResourceNotFound(
String::from(error_message),
))
}
"TooManyRequestsException" => {
return RusotoError::Service(DeleteProjectError::TooManyRequests(String::from(
error_message,
)))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteProjectError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteProjectError {
fn description(&self) -> &str {
match *self {
DeleteProjectError::InternalFailure(ref cause) => cause,
DeleteProjectError::InvalidRequest(ref cause) => cause,
DeleteProjectError::ResourceNotFound(ref cause) => cause,
DeleteProjectError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribePlacementError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl DescribePlacementError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribePlacementError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(DescribePlacementError::InternalFailure(
String::from(error_message),
))
}
"InvalidRequestException" => {
return RusotoError::Service(DescribePlacementError::InvalidRequest(
String::from(error_message),
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DescribePlacementError::ResourceNotFound(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribePlacementError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribePlacementError {
fn description(&self) -> &str {
match *self {
DescribePlacementError::InternalFailure(ref cause) => cause,
DescribePlacementError::InvalidRequest(ref cause) => cause,
DescribePlacementError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeProjectError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl DescribeProjectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeProjectError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(DescribeProjectError::InternalFailure(
String::from(error_message),
))
}
"InvalidRequestException" => {
return RusotoError::Service(DescribeProjectError::InvalidRequest(
String::from(error_message),
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(DescribeProjectError::ResourceNotFound(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeProjectError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeProjectError {
fn description(&self) -> &str {
match *self {
DescribeProjectError::InternalFailure(ref cause) => cause,
DescribeProjectError::InvalidRequest(ref cause) => cause,
DescribeProjectError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DisassociateDeviceFromPlacementError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
TooManyRequests(String),
}
impl DisassociateDeviceFromPlacementError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<DisassociateDeviceFromPlacementError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(
DisassociateDeviceFromPlacementError::InternalFailure(String::from(
error_message,
)),
)
}
"InvalidRequestException" => {
return RusotoError::Service(
DisassociateDeviceFromPlacementError::InvalidRequest(String::from(
error_message,
)),
)
}
"ResourceNotFoundException" => {
return RusotoError::Service(
DisassociateDeviceFromPlacementError::ResourceNotFound(String::from(
error_message,
)),
)
}
"TooManyRequestsException" => {
return RusotoError::Service(
DisassociateDeviceFromPlacementError::TooManyRequests(String::from(
error_message,
)),
)
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DisassociateDeviceFromPlacementError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DisassociateDeviceFromPlacementError {
fn description(&self) -> &str {
match *self {
DisassociateDeviceFromPlacementError::InternalFailure(ref cause) => cause,
DisassociateDeviceFromPlacementError::InvalidRequest(ref cause) => cause,
DisassociateDeviceFromPlacementError::ResourceNotFound(ref cause) => cause,
DisassociateDeviceFromPlacementError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetDevicesInPlacementError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl GetDevicesInPlacementError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetDevicesInPlacementError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(GetDevicesInPlacementError::InternalFailure(
String::from(error_message),
))
}
"InvalidRequestException" => {
return RusotoError::Service(GetDevicesInPlacementError::InvalidRequest(
String::from(error_message),
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(GetDevicesInPlacementError::ResourceNotFound(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetDevicesInPlacementError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetDevicesInPlacementError {
fn description(&self) -> &str {
match *self {
GetDevicesInPlacementError::InternalFailure(ref cause) => cause,
GetDevicesInPlacementError::InvalidRequest(ref cause) => cause,
GetDevicesInPlacementError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListPlacementsError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
}
impl ListPlacementsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListPlacementsError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(ListPlacementsError::InternalFailure(
String::from(error_message),
))
}
"InvalidRequestException" => {
return RusotoError::Service(ListPlacementsError::InvalidRequest(String::from(
error_message,
)))
}
"ResourceNotFoundException" => {
return RusotoError::Service(ListPlacementsError::ResourceNotFound(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListPlacementsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListPlacementsError {
fn description(&self) -> &str {
match *self {
ListPlacementsError::InternalFailure(ref cause) => cause,
ListPlacementsError::InvalidRequest(ref cause) => cause,
ListPlacementsError::ResourceNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListProjectsError {
InternalFailure(String),
InvalidRequest(String),
}
impl ListProjectsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListProjectsError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(ListProjectsError::InternalFailure(String::from(
error_message,
)))
}
"InvalidRequestException" => {
return RusotoError::Service(ListProjectsError::InvalidRequest(String::from(
error_message,
)))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListProjectsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListProjectsError {
fn description(&self) -> &str {
match *self {
ListProjectsError::InternalFailure(ref cause) => cause,
ListProjectsError::InvalidRequest(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdatePlacementError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
TooManyRequests(String),
}
impl UpdatePlacementError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UpdatePlacementError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(UpdatePlacementError::InternalFailure(
String::from(error_message),
))
}
"InvalidRequestException" => {
return RusotoError::Service(UpdatePlacementError::InvalidRequest(
String::from(error_message),
))
}
"ResourceNotFoundException" => {
return RusotoError::Service(UpdatePlacementError::ResourceNotFound(
String::from(error_message),
))
}
"TooManyRequestsException" => {
return RusotoError::Service(UpdatePlacementError::TooManyRequests(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UpdatePlacementError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdatePlacementError {
fn description(&self) -> &str {
match *self {
UpdatePlacementError::InternalFailure(ref cause) => cause,
UpdatePlacementError::InvalidRequest(ref cause) => cause,
UpdatePlacementError::ResourceNotFound(ref cause) => cause,
UpdatePlacementError::TooManyRequests(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateProjectError {
InternalFailure(String),
InvalidRequest(String),
ResourceNotFound(String),
TooManyRequests(String),
}
impl UpdateProjectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UpdateProjectError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalFailureException" => {
return RusotoError::Service(UpdateProjectError::InternalFailure(String::from(
error_message,
)))
}
"InvalidRequestException" => {
return RusotoError::Service(UpdateProjectError::InvalidRequest(String::from(
error_message,
)))
}
"ResourceNotFoundException" => {
return RusotoError::Service(UpdateProjectError::ResourceNotFound(
String::from(error_message),
))
}
"TooManyRequestsException" => {
return RusotoError::Service(UpdateProjectError::TooManyRequests(String::from(
error_message,
)))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UpdateProjectError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateProjectError {
fn description(&self) -> &str {
match *self {
UpdateProjectError::InternalFailure(ref cause) => cause,
UpdateProjectError::InvalidRequest(ref cause) => cause,
UpdateProjectError::ResourceNotFound(ref cause) => cause,
UpdateProjectError::TooManyRequests(ref cause) => cause,
}
}
}
pub trait Iot1ClickProjects {
fn associate_device_with_placement(
&self,
input: AssociateDeviceWithPlacementRequest,
) -> RusotoFuture<AssociateDeviceWithPlacementResponse, AssociateDeviceWithPlacementError>;
fn create_placement(
&self,
input: CreatePlacementRequest,
) -> RusotoFuture<CreatePlacementResponse, CreatePlacementError>;
fn create_project(
&self,
input: CreateProjectRequest,
) -> RusotoFuture<CreateProjectResponse, CreateProjectError>;
fn delete_placement(
&self,
input: DeletePlacementRequest,
) -> RusotoFuture<DeletePlacementResponse, DeletePlacementError>;
fn delete_project(
&self,
input: DeleteProjectRequest,
) -> RusotoFuture<DeleteProjectResponse, DeleteProjectError>;
fn describe_placement(
&self,
input: DescribePlacementRequest,
) -> RusotoFuture<DescribePlacementResponse, DescribePlacementError>;
fn describe_project(
&self,
input: DescribeProjectRequest,
) -> RusotoFuture<DescribeProjectResponse, DescribeProjectError>;
fn disassociate_device_from_placement(
&self,
input: DisassociateDeviceFromPlacementRequest,
) -> RusotoFuture<DisassociateDeviceFromPlacementResponse, DisassociateDeviceFromPlacementError>;
fn get_devices_in_placement(
&self,
input: GetDevicesInPlacementRequest,
) -> RusotoFuture<GetDevicesInPlacementResponse, GetDevicesInPlacementError>;
fn list_placements(
&self,
input: ListPlacementsRequest,
) -> RusotoFuture<ListPlacementsResponse, ListPlacementsError>;
fn list_projects(
&self,
input: ListProjectsRequest,
) -> RusotoFuture<ListProjectsResponse, ListProjectsError>;
fn update_placement(
&self,
input: UpdatePlacementRequest,
) -> RusotoFuture<UpdatePlacementResponse, UpdatePlacementError>;
fn update_project(
&self,
input: UpdateProjectRequest,
) -> RusotoFuture<UpdateProjectResponse, UpdateProjectError>;
}
#[derive(Clone)]
pub struct Iot1ClickProjectsClient {
client: Client,
region: region::Region,
}
impl Iot1ClickProjectsClient {
pub fn new(region: region::Region) -> Iot1ClickProjectsClient {
Iot1ClickProjectsClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> Iot1ClickProjectsClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
Iot1ClickProjectsClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl Iot1ClickProjects for Iot1ClickProjectsClient {
fn associate_device_with_placement(
&self,
input: AssociateDeviceWithPlacementRequest,
) -> RusotoFuture<AssociateDeviceWithPlacementResponse, AssociateDeviceWithPlacementError> {
let request_uri = format!(
"/projects/{project_name}/placements/{placement_name}/devices/{device_template_name}",
device_template_name = input.device_template_name,
placement_name = input.placement_name,
project_name = input.project_name
);
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("projects.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.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<AssociateDeviceWithPlacementResponse>(&body)
.unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(AssociateDeviceWithPlacementError::from_response(response))
}))
}
})
}
fn create_placement(
&self,
input: CreatePlacementRequest,
) -> RusotoFuture<CreatePlacementResponse, CreatePlacementError> {
let request_uri = format!(
"/projects/{project_name}/placements",
project_name = input.project_name
);
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("projects.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.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<CreatePlacementResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreatePlacementError::from_response(response))),
)
}
})
}
fn create_project(
&self,
input: CreateProjectRequest,
) -> RusotoFuture<CreateProjectResponse, CreateProjectError> {
let request_uri = "/projects";
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("projects.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.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<CreateProjectResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateProjectError::from_response(response))),
)
}
})
}
fn delete_placement(
&self,
input: DeletePlacementRequest,
) -> RusotoFuture<DeletePlacementResponse, DeletePlacementError> {
let request_uri = format!(
"/projects/{project_name}/placements/{placement_name}",
placement_name = input.placement_name,
project_name = input.project_name
);
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("projects.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<DeletePlacementResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeletePlacementError::from_response(response))),
)
}
})
}
fn delete_project(
&self,
input: DeleteProjectRequest,
) -> RusotoFuture<DeleteProjectResponse, DeleteProjectError> {
let request_uri = format!(
"/projects/{project_name}",
project_name = input.project_name
);
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("projects.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<DeleteProjectResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteProjectError::from_response(response))),
)
}
})
}
fn describe_placement(
&self,
input: DescribePlacementRequest,
) -> RusotoFuture<DescribePlacementResponse, DescribePlacementError> {
let request_uri = format!(
"/projects/{project_name}/placements/{placement_name}",
placement_name = input.placement_name,
project_name = input.project_name
);
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("projects.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<DescribePlacementResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribePlacementError::from_response(response))),
)
}
})
}
fn describe_project(
&self,
input: DescribeProjectRequest,
) -> RusotoFuture<DescribeProjectResponse, DescribeProjectError> {
let request_uri = format!(
"/projects/{project_name}",
project_name = input.project_name
);
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("projects.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<DescribeProjectResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeProjectError::from_response(response))),
)
}
})
}
fn disassociate_device_from_placement(
&self,
input: DisassociateDeviceFromPlacementRequest,
) -> RusotoFuture<DisassociateDeviceFromPlacementResponse, DisassociateDeviceFromPlacementError>
{
let request_uri = format!(
"/projects/{project_name}/placements/{placement_name}/devices/{device_template_name}",
device_template_name = input.device_template_name,
placement_name = input.placement_name,
project_name = input.project_name
);
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("projects.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<DisassociateDeviceFromPlacementResponse>(&body)
.unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DisassociateDeviceFromPlacementError::from_response(
response,
))
}))
}
})
}
fn get_devices_in_placement(
&self,
input: GetDevicesInPlacementRequest,
) -> RusotoFuture<GetDevicesInPlacementResponse, GetDevicesInPlacementError> {
let request_uri = format!(
"/projects/{project_name}/placements/{placement_name}/devices",
placement_name = input.placement_name,
project_name = input.project_name
);
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("projects.iot1click".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<GetDevicesInPlacementResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(GetDevicesInPlacementError::from_response(response))
}),
)
}
})
}
fn list_placements(
&self,
input: ListPlacementsRequest,
) -> RusotoFuture<ListPlacementsResponse, ListPlacementsError> {
let request_uri = format!(
"/projects/{project_name}/placements",
project_name = input.project_name
);
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("projects.iot1click".to_string());
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().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<ListPlacementsResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListPlacementsError::from_response(response))),
)
}
})
}
fn list_projects(
&self,
input: ListProjectsRequest,
) -> RusotoFuture<ListProjectsResponse, ListProjectsError> {
let request_uri = "/projects";
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("projects.iot1click".to_string());
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().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<ListProjectsResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListProjectsError::from_response(response))),
)
}
})
}
fn update_placement(
&self,
input: UpdatePlacementRequest,
) -> RusotoFuture<UpdatePlacementResponse, UpdatePlacementError> {
let request_uri = format!(
"/projects/{project_name}/placements/{placement_name}",
placement_name = input.placement_name,
project_name = input.project_name
);
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("projects.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.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<UpdatePlacementResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdatePlacementError::from_response(response))),
)
}
})
}
fn update_project(
&self,
input: UpdateProjectRequest,
) -> RusotoFuture<UpdateProjectResponse, UpdateProjectError> {
let request_uri = format!(
"/projects/{project_name}",
project_name = input.project_name
);
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("projects.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.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<UpdateProjectResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateProjectError::from_response(response))),
)
}
})
}
}
#[cfg(test)]
mod protocol_tests {}