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;
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BundleDetails {
#[serde(rename = "availablePlatforms")]
#[serde(skip_serializing_if = "Option::is_none")]
pub available_platforms: Option<Vec<String>>,
#[serde(rename = "bundleId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bundle_id: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "iconUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_url: Option<String>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateProjectRequest {
#[serde(rename = "contents")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub contents: Option<bytes::Bytes>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "region")]
#[serde(skip_serializing_if = "Option::is_none")]
pub region: Option<String>,
#[serde(rename = "snapshotId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub snapshot_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateProjectResult {
#[serde(rename = "details")]
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<ProjectDetails>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteProjectRequest {
#[serde(rename = "projectId")]
pub project_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteProjectResult {
#[serde(rename = "deletedResources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deleted_resources: Option<Vec<Resource>>,
#[serde(rename = "orphanedResources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub orphaned_resources: Option<Vec<Resource>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeBundleRequest {
#[serde(rename = "bundleId")]
pub bundle_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeBundleResult {
#[serde(rename = "details")]
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<BundleDetails>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeProjectRequest {
#[serde(rename = "projectId")]
pub project_id: String,
#[serde(rename = "syncFromResources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_from_resources: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeProjectResult {
#[serde(rename = "details")]
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<ProjectDetails>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ExportBundleRequest {
#[serde(rename = "bundleId")]
pub bundle_id: String,
#[serde(rename = "platform")]
#[serde(skip_serializing_if = "Option::is_none")]
pub platform: Option<String>,
#[serde(rename = "projectId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub project_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ExportBundleResult {
#[serde(rename = "downloadUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub download_url: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ExportProjectRequest {
#[serde(rename = "projectId")]
pub project_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ExportProjectResult {
#[serde(rename = "downloadUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub download_url: Option<String>,
#[serde(rename = "shareUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub share_url: Option<String>,
#[serde(rename = "snapshotId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub snapshot_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListBundlesRequest {
#[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 ListBundlesResult {
#[serde(rename = "bundleList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bundle_list: Option<Vec<BundleDetails>>,
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[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 ListProjectsResult {
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "projects")]
#[serde(skip_serializing_if = "Option::is_none")]
pub projects: Option<Vec<ProjectSummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ProjectDetails {
#[serde(rename = "consoleUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub console_url: Option<String>,
#[serde(rename = "createdDate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date: Option<f64>,
#[serde(rename = "lastUpdatedDate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_updated_date: Option<f64>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "projectId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub project_id: Option<String>,
#[serde(rename = "region")]
#[serde(skip_serializing_if = "Option::is_none")]
pub region: Option<String>,
#[serde(rename = "resources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resources: Option<Vec<Resource>>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ProjectSummary {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "projectId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub project_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Resource {
#[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 = "feature")]
#[serde(skip_serializing_if = "Option::is_none")]
pub feature: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateProjectRequest {
#[serde(rename = "contents")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub contents: Option<bytes::Bytes>,
#[serde(rename = "projectId")]
pub project_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateProjectResult {
#[serde(rename = "details")]
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<ProjectDetails>,
}
#[derive(Debug, PartialEq)]
pub enum CreateProjectError {
BadRequest(String),
InternalFailure(String),
LimitExceeded(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
Unauthorized(String),
}
impl CreateProjectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateProjectError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(CreateProjectError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(CreateProjectError::InternalFailure(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(CreateProjectError::LimitExceeded(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(CreateProjectError::NotFound(err.msg))
}
"ServiceUnavailableException" => {
return RusotoError::Service(CreateProjectError::ServiceUnavailable(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(CreateProjectError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(CreateProjectError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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::BadRequest(ref cause) => cause,
CreateProjectError::InternalFailure(ref cause) => cause,
CreateProjectError::LimitExceeded(ref cause) => cause,
CreateProjectError::NotFound(ref cause) => cause,
CreateProjectError::ServiceUnavailable(ref cause) => cause,
CreateProjectError::TooManyRequests(ref cause) => cause,
CreateProjectError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteProjectError {
InternalFailure(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
Unauthorized(String),
}
impl DeleteProjectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteProjectError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalFailureException" => {
return RusotoError::Service(DeleteProjectError::InternalFailure(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(DeleteProjectError::NotFound(err.msg))
}
"ServiceUnavailableException" => {
return RusotoError::Service(DeleteProjectError::ServiceUnavailable(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(DeleteProjectError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(DeleteProjectError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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::NotFound(ref cause) => cause,
DeleteProjectError::ServiceUnavailable(ref cause) => cause,
DeleteProjectError::TooManyRequests(ref cause) => cause,
DeleteProjectError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeBundleError {
BadRequest(String),
InternalFailure(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
Unauthorized(String),
}
impl DescribeBundleError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeBundleError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(DescribeBundleError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(DescribeBundleError::InternalFailure(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(DescribeBundleError::NotFound(err.msg))
}
"ServiceUnavailableException" => {
return RusotoError::Service(DescribeBundleError::ServiceUnavailable(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(DescribeBundleError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(DescribeBundleError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeBundleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeBundleError {
fn description(&self) -> &str {
match *self {
DescribeBundleError::BadRequest(ref cause) => cause,
DescribeBundleError::InternalFailure(ref cause) => cause,
DescribeBundleError::NotFound(ref cause) => cause,
DescribeBundleError::ServiceUnavailable(ref cause) => cause,
DescribeBundleError::TooManyRequests(ref cause) => cause,
DescribeBundleError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeProjectError {
BadRequest(String),
InternalFailure(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
Unauthorized(String),
}
impl DescribeProjectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeProjectError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(DescribeProjectError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(DescribeProjectError::InternalFailure(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(DescribeProjectError::NotFound(err.msg))
}
"ServiceUnavailableException" => {
return RusotoError::Service(DescribeProjectError::ServiceUnavailable(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(DescribeProjectError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(DescribeProjectError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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::BadRequest(ref cause) => cause,
DescribeProjectError::InternalFailure(ref cause) => cause,
DescribeProjectError::NotFound(ref cause) => cause,
DescribeProjectError::ServiceUnavailable(ref cause) => cause,
DescribeProjectError::TooManyRequests(ref cause) => cause,
DescribeProjectError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ExportBundleError {
BadRequest(String),
InternalFailure(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
Unauthorized(String),
}
impl ExportBundleError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ExportBundleError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ExportBundleError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(ExportBundleError::InternalFailure(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(ExportBundleError::NotFound(err.msg))
}
"ServiceUnavailableException" => {
return RusotoError::Service(ExportBundleError::ServiceUnavailable(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(ExportBundleError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(ExportBundleError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ExportBundleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ExportBundleError {
fn description(&self) -> &str {
match *self {
ExportBundleError::BadRequest(ref cause) => cause,
ExportBundleError::InternalFailure(ref cause) => cause,
ExportBundleError::NotFound(ref cause) => cause,
ExportBundleError::ServiceUnavailable(ref cause) => cause,
ExportBundleError::TooManyRequests(ref cause) => cause,
ExportBundleError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ExportProjectError {
BadRequest(String),
InternalFailure(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
Unauthorized(String),
}
impl ExportProjectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ExportProjectError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ExportProjectError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(ExportProjectError::InternalFailure(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(ExportProjectError::NotFound(err.msg))
}
"ServiceUnavailableException" => {
return RusotoError::Service(ExportProjectError::ServiceUnavailable(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(ExportProjectError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(ExportProjectError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ExportProjectError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ExportProjectError {
fn description(&self) -> &str {
match *self {
ExportProjectError::BadRequest(ref cause) => cause,
ExportProjectError::InternalFailure(ref cause) => cause,
ExportProjectError::NotFound(ref cause) => cause,
ExportProjectError::ServiceUnavailable(ref cause) => cause,
ExportProjectError::TooManyRequests(ref cause) => cause,
ExportProjectError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListBundlesError {
BadRequest(String),
InternalFailure(String),
ServiceUnavailable(String),
TooManyRequests(String),
Unauthorized(String),
}
impl ListBundlesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListBundlesError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ListBundlesError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(ListBundlesError::InternalFailure(err.msg))
}
"ServiceUnavailableException" => {
return RusotoError::Service(ListBundlesError::ServiceUnavailable(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(ListBundlesError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(ListBundlesError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListBundlesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListBundlesError {
fn description(&self) -> &str {
match *self {
ListBundlesError::BadRequest(ref cause) => cause,
ListBundlesError::InternalFailure(ref cause) => cause,
ListBundlesError::ServiceUnavailable(ref cause) => cause,
ListBundlesError::TooManyRequests(ref cause) => cause,
ListBundlesError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListProjectsError {
BadRequest(String),
InternalFailure(String),
ServiceUnavailable(String),
TooManyRequests(String),
Unauthorized(String),
}
impl ListProjectsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListProjectsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ListProjectsError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(ListProjectsError::InternalFailure(err.msg))
}
"ServiceUnavailableException" => {
return RusotoError::Service(ListProjectsError::ServiceUnavailable(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(ListProjectsError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(ListProjectsError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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::BadRequest(ref cause) => cause,
ListProjectsError::InternalFailure(ref cause) => cause,
ListProjectsError::ServiceUnavailable(ref cause) => cause,
ListProjectsError::TooManyRequests(ref cause) => cause,
ListProjectsError::Unauthorized(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateProjectError {
AccountActionRequired(String),
BadRequest(String),
InternalFailure(String),
LimitExceeded(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
Unauthorized(String),
}
impl UpdateProjectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UpdateProjectError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"AccountActionRequiredException" => {
return RusotoError::Service(UpdateProjectError::AccountActionRequired(err.msg))
}
"BadRequestException" => {
return RusotoError::Service(UpdateProjectError::BadRequest(err.msg))
}
"InternalFailureException" => {
return RusotoError::Service(UpdateProjectError::InternalFailure(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(UpdateProjectError::LimitExceeded(err.msg))
}
"NotFoundException" => {
return RusotoError::Service(UpdateProjectError::NotFound(err.msg))
}
"ServiceUnavailableException" => {
return RusotoError::Service(UpdateProjectError::ServiceUnavailable(err.msg))
}
"TooManyRequestsException" => {
return RusotoError::Service(UpdateProjectError::TooManyRequests(err.msg))
}
"UnauthorizedException" => {
return RusotoError::Service(UpdateProjectError::Unauthorized(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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::AccountActionRequired(ref cause) => cause,
UpdateProjectError::BadRequest(ref cause) => cause,
UpdateProjectError::InternalFailure(ref cause) => cause,
UpdateProjectError::LimitExceeded(ref cause) => cause,
UpdateProjectError::NotFound(ref cause) => cause,
UpdateProjectError::ServiceUnavailable(ref cause) => cause,
UpdateProjectError::TooManyRequests(ref cause) => cause,
UpdateProjectError::Unauthorized(ref cause) => cause,
}
}
}
pub trait Mobile {
fn create_project(
&self,
input: CreateProjectRequest,
) -> RusotoFuture<CreateProjectResult, CreateProjectError>;
fn delete_project(
&self,
input: DeleteProjectRequest,
) -> RusotoFuture<DeleteProjectResult, DeleteProjectError>;
fn describe_bundle(
&self,
input: DescribeBundleRequest,
) -> RusotoFuture<DescribeBundleResult, DescribeBundleError>;
fn describe_project(
&self,
input: DescribeProjectRequest,
) -> RusotoFuture<DescribeProjectResult, DescribeProjectError>;
fn export_bundle(
&self,
input: ExportBundleRequest,
) -> RusotoFuture<ExportBundleResult, ExportBundleError>;
fn export_project(
&self,
input: ExportProjectRequest,
) -> RusotoFuture<ExportProjectResult, ExportProjectError>;
fn list_bundles(
&self,
input: ListBundlesRequest,
) -> RusotoFuture<ListBundlesResult, ListBundlesError>;
fn list_projects(
&self,
input: ListProjectsRequest,
) -> RusotoFuture<ListProjectsResult, ListProjectsError>;
fn update_project(
&self,
input: UpdateProjectRequest,
) -> RusotoFuture<UpdateProjectResult, UpdateProjectError>;
}
#[derive(Clone)]
pub struct MobileClient {
client: Client,
region: region::Region,
}
impl MobileClient {
pub fn new(region: region::Region) -> MobileClient {
MobileClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> MobileClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
MobileClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl Mobile for MobileClient {
fn create_project(
&self,
input: CreateProjectRequest,
) -> RusotoFuture<CreateProjectResult, CreateProjectError> {
let request_uri = "/projects";
let mut request =
SignedRequest::new("POST", "AWSMobileHubService", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("mobile".to_string());
let encoded = if let Some(ref payload) = input.contents {
Some(payload.to_owned())
} else {
None
};
request.set_payload(encoded);
let mut params = Params::new();
if let Some(ref x) = input.name {
params.put("name", x);
}
if let Some(ref x) = input.region {
params.put("region", x);
}
if let Some(ref x) = input.snapshot_id {
params.put("snapshotId", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<CreateProjectResult, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateProjectError::from_response(response))),
)
}
})
}
fn delete_project(
&self,
input: DeleteProjectRequest,
) -> RusotoFuture<DeleteProjectResult, DeleteProjectError> {
let request_uri = format!("/projects/{project_id}", project_id = input.project_id);
let mut request =
SignedRequest::new("DELETE", "AWSMobileHubService", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("mobile".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteProjectResult, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteProjectError::from_response(response))),
)
}
})
}
fn describe_bundle(
&self,
input: DescribeBundleRequest,
) -> RusotoFuture<DescribeBundleResult, DescribeBundleError> {
let request_uri = format!("/bundles/{bundle_id}", bundle_id = input.bundle_id);
let mut request =
SignedRequest::new("GET", "AWSMobileHubService", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("mobile".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeBundleResult, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeBundleError::from_response(response))),
)
}
})
}
fn describe_project(
&self,
input: DescribeProjectRequest,
) -> RusotoFuture<DescribeProjectResult, DescribeProjectError> {
let request_uri = "/project";
let mut request =
SignedRequest::new("GET", "AWSMobileHubService", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("mobile".to_string());
let mut params = Params::new();
params.put("projectId", &input.project_id);
if let Some(ref x) = input.sync_from_resources {
params.put("syncFromResources", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeProjectResult, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeProjectError::from_response(response))),
)
}
})
}
fn export_bundle(
&self,
input: ExportBundleRequest,
) -> RusotoFuture<ExportBundleResult, ExportBundleError> {
let request_uri = format!("/bundles/{bundle_id}", bundle_id = input.bundle_id);
let mut request =
SignedRequest::new("POST", "AWSMobileHubService", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("mobile".to_string());
let mut params = Params::new();
if let Some(ref x) = input.platform {
params.put("platform", x);
}
if let Some(ref x) = input.project_id {
params.put("projectId", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ExportBundleResult, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ExportBundleError::from_response(response))),
)
}
})
}
fn export_project(
&self,
input: ExportProjectRequest,
) -> RusotoFuture<ExportProjectResult, ExportProjectError> {
let request_uri = format!("/exports/{project_id}", project_id = input.project_id);
let mut request =
SignedRequest::new("POST", "AWSMobileHubService", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("mobile".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ExportProjectResult, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ExportProjectError::from_response(response))),
)
}
})
}
fn list_bundles(
&self,
input: ListBundlesRequest,
) -> RusotoFuture<ListBundlesResult, ListBundlesError> {
let request_uri = "/bundles";
let mut request =
SignedRequest::new("GET", "AWSMobileHubService", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("mobile".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().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListBundlesResult, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListBundlesError::from_response(response))),
)
}
})
}
fn list_projects(
&self,
input: ListProjectsRequest,
) -> RusotoFuture<ListProjectsResult, ListProjectsError> {
let request_uri = "/projects";
let mut request =
SignedRequest::new("GET", "AWSMobileHubService", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("mobile".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().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListProjectsResult, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListProjectsError::from_response(response))),
)
}
})
}
fn update_project(
&self,
input: UpdateProjectRequest,
) -> RusotoFuture<UpdateProjectResult, UpdateProjectError> {
let request_uri = "/update";
let mut request =
SignedRequest::new("POST", "AWSMobileHubService", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("mobile".to_string());
let encoded = if let Some(ref payload) = input.contents {
Some(payload.to_owned())
} else {
None
};
request.set_payload(encoded);
let mut params = Params::new();
params.put("projectId", &input.project_id);
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<UpdateProjectResult, _>()?;
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateProjectError::from_response(response))),
)
}
})
}
}