use std::error::Error;
use std::fmt;
use std::io;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoFuture};
use rusoto_core::credential::{CredentialsError, ProvideAwsCredentials};
use rusoto_core::request::HttpDispatchError;
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, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Channel {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsIngest")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_ingest: Option<HlsIngest>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct ChannelCreateParameters {
pub description: Option<String>,
pub id: String,
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct ChannelList {
pub channels: Option<Vec<Channel>>,
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct ChannelUpdateParameters {
pub description: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CmafEncryption {
#[serde(rename = "KeyRotationIntervalSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_rotation_interval_seconds: Option<i64>,
#[serde(rename = "SpekeKeyProvider")]
pub speke_key_provider: SpekeKeyProvider,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CmafPackage {
#[serde(rename = "Encryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption: Option<CmafEncryption>,
#[serde(rename = "HlsManifests")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_manifests: Option<Vec<HlsManifest>>,
#[serde(rename = "SegmentDurationSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segment_duration_seconds: Option<i64>,
#[serde(rename = "SegmentPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segment_prefix: Option<String>,
#[serde(rename = "StreamSelection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub stream_selection: Option<StreamSelection>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CmafPackageCreateOrUpdateParameters {
#[serde(rename = "Encryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption: Option<CmafEncryption>,
#[serde(rename = "HlsManifests")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_manifests: Option<Vec<HlsManifestCreateOrUpdateParameters>>,
#[serde(rename = "SegmentDurationSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segment_duration_seconds: Option<i64>,
#[serde(rename = "SegmentPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segment_prefix: Option<String>,
#[serde(rename = "StreamSelection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub stream_selection: Option<StreamSelection>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateChannelRequest {
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Id")]
pub id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateChannelResponse {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsIngest")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_ingest: Option<HlsIngest>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateOriginEndpointRequest {
#[serde(rename = "ChannelId")]
pub channel_id: String,
#[serde(rename = "CmafPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cmaf_package: Option<CmafPackageCreateOrUpdateParameters>,
#[serde(rename = "DashPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_package: Option<DashPackage>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_package: Option<HlsPackage>,
#[serde(rename = "Id")]
pub id: String,
#[serde(rename = "ManifestName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_name: Option<String>,
#[serde(rename = "MssPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mss_package: Option<MssPackage>,
#[serde(rename = "StartoverWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub startover_window_seconds: Option<i64>,
#[serde(rename = "TimeDelaySeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_delay_seconds: Option<i64>,
#[serde(rename = "Whitelist")]
#[serde(skip_serializing_if = "Option::is_none")]
pub whitelist: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateOriginEndpointResponse {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "ChannelId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
#[serde(rename = "CmafPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cmaf_package: Option<CmafPackage>,
#[serde(rename = "DashPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_package: Option<DashPackage>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_package: Option<HlsPackage>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "ManifestName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_name: Option<String>,
#[serde(rename = "MssPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mss_package: Option<MssPackage>,
#[serde(rename = "StartoverWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub startover_window_seconds: Option<i64>,
#[serde(rename = "TimeDelaySeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_delay_seconds: Option<i64>,
#[serde(rename = "Url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(rename = "Whitelist")]
#[serde(skip_serializing_if = "Option::is_none")]
pub whitelist: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DashEncryption {
#[serde(rename = "KeyRotationIntervalSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_rotation_interval_seconds: Option<i64>,
#[serde(rename = "SpekeKeyProvider")]
pub speke_key_provider: SpekeKeyProvider,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DashPackage {
#[serde(rename = "Encryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption: Option<DashEncryption>,
#[serde(rename = "ManifestLayout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_layout: Option<String>,
#[serde(rename = "ManifestWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_window_seconds: Option<i64>,
#[serde(rename = "MinBufferTimeSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub min_buffer_time_seconds: Option<i64>,
#[serde(rename = "MinUpdatePeriodSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub min_update_period_seconds: Option<i64>,
#[serde(rename = "PeriodTriggers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub period_triggers: Option<Vec<String>>,
#[serde(rename = "Profile")]
#[serde(skip_serializing_if = "Option::is_none")]
pub profile: Option<String>,
#[serde(rename = "SegmentDurationSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segment_duration_seconds: Option<i64>,
#[serde(rename = "SegmentTemplateFormat")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segment_template_format: Option<String>,
#[serde(rename = "StreamSelection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub stream_selection: Option<StreamSelection>,
#[serde(rename = "SuggestedPresentationDelaySeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub suggested_presentation_delay_seconds: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteChannelRequest {
#[serde(rename = "Id")]
pub id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteChannelResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteOriginEndpointRequest {
#[serde(rename = "Id")]
pub id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteOriginEndpointResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeChannelRequest {
#[serde(rename = "Id")]
pub id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeChannelResponse {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsIngest")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_ingest: Option<HlsIngest>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeOriginEndpointRequest {
#[serde(rename = "Id")]
pub id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeOriginEndpointResponse {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "ChannelId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
#[serde(rename = "CmafPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cmaf_package: Option<CmafPackage>,
#[serde(rename = "DashPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_package: Option<DashPackage>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_package: Option<HlsPackage>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "ManifestName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_name: Option<String>,
#[serde(rename = "MssPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mss_package: Option<MssPackage>,
#[serde(rename = "StartoverWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub startover_window_seconds: Option<i64>,
#[serde(rename = "TimeDelaySeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_delay_seconds: Option<i64>,
#[serde(rename = "Url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(rename = "Whitelist")]
#[serde(skip_serializing_if = "Option::is_none")]
pub whitelist: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HlsEncryption {
#[serde(rename = "ConstantInitializationVector")]
#[serde(skip_serializing_if = "Option::is_none")]
pub constant_initialization_vector: Option<String>,
#[serde(rename = "EncryptionMethod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption_method: Option<String>,
#[serde(rename = "KeyRotationIntervalSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_rotation_interval_seconds: Option<i64>,
#[serde(rename = "RepeatExtXKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub repeat_ext_x_key: Option<bool>,
#[serde(rename = "SpekeKeyProvider")]
pub speke_key_provider: SpekeKeyProvider,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct HlsIngest {
#[serde(rename = "IngestEndpoints")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ingest_endpoints: Option<Vec<IngestEndpoint>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct HlsManifest {
#[serde(rename = "AdMarkers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ad_markers: Option<String>,
#[serde(rename = "Id")]
pub id: String,
#[serde(rename = "IncludeIframeOnlyStream")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_iframe_only_stream: Option<bool>,
#[serde(rename = "ManifestName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_name: Option<String>,
#[serde(rename = "PlaylistType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playlist_type: Option<String>,
#[serde(rename = "PlaylistWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playlist_window_seconds: Option<i64>,
#[serde(rename = "ProgramDateTimeIntervalSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub program_date_time_interval_seconds: Option<i64>,
#[serde(rename = "Url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct HlsManifestCreateOrUpdateParameters {
#[serde(rename = "AdMarkers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ad_markers: Option<String>,
#[serde(rename = "Id")]
pub id: String,
#[serde(rename = "IncludeIframeOnlyStream")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_iframe_only_stream: Option<bool>,
#[serde(rename = "ManifestName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_name: Option<String>,
#[serde(rename = "PlaylistType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playlist_type: Option<String>,
#[serde(rename = "PlaylistWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playlist_window_seconds: Option<i64>,
#[serde(rename = "ProgramDateTimeIntervalSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub program_date_time_interval_seconds: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct HlsPackage {
#[serde(rename = "AdMarkers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ad_markers: Option<String>,
#[serde(rename = "Encryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption: Option<HlsEncryption>,
#[serde(rename = "IncludeIframeOnlyStream")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_iframe_only_stream: Option<bool>,
#[serde(rename = "PlaylistType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playlist_type: Option<String>,
#[serde(rename = "PlaylistWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playlist_window_seconds: Option<i64>,
#[serde(rename = "ProgramDateTimeIntervalSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub program_date_time_interval_seconds: Option<i64>,
#[serde(rename = "SegmentDurationSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segment_duration_seconds: Option<i64>,
#[serde(rename = "StreamSelection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub stream_selection: Option<StreamSelection>,
#[serde(rename = "UseAudioRenditionGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub use_audio_rendition_group: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct IngestEndpoint {
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "Password")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password: Option<String>,
#[serde(rename = "Url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(rename = "Username")]
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListChannelsRequest {
#[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 ListChannelsResponse {
#[serde(rename = "Channels")]
#[serde(skip_serializing_if = "Option::is_none")]
pub channels: Option<Vec<Channel>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListOriginEndpointsRequest {
#[serde(rename = "ChannelId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: 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 ListOriginEndpointsResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "OriginEndpoints")]
#[serde(skip_serializing_if = "Option::is_none")]
pub origin_endpoints: Option<Vec<OriginEndpoint>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MssEncryption {
#[serde(rename = "SpekeKeyProvider")]
pub speke_key_provider: SpekeKeyProvider,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MssPackage {
#[serde(rename = "Encryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption: Option<MssEncryption>,
#[serde(rename = "ManifestWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_window_seconds: Option<i64>,
#[serde(rename = "SegmentDurationSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segment_duration_seconds: Option<i64>,
#[serde(rename = "StreamSelection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub stream_selection: Option<StreamSelection>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct OriginEndpoint {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "ChannelId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
#[serde(rename = "CmafPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cmaf_package: Option<CmafPackage>,
#[serde(rename = "DashPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_package: Option<DashPackage>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_package: Option<HlsPackage>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "ManifestName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_name: Option<String>,
#[serde(rename = "MssPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mss_package: Option<MssPackage>,
#[serde(rename = "StartoverWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub startover_window_seconds: Option<i64>,
#[serde(rename = "TimeDelaySeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_delay_seconds: Option<i64>,
#[serde(rename = "Url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(rename = "Whitelist")]
#[serde(skip_serializing_if = "Option::is_none")]
pub whitelist: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct OriginEndpointCreateParameters {
pub channel_id: String,
pub cmaf_package: Option<CmafPackageCreateOrUpdateParameters>,
pub dash_package: Option<DashPackage>,
pub description: Option<String>,
pub hls_package: Option<HlsPackage>,
pub id: String,
pub manifest_name: Option<String>,
pub mss_package: Option<MssPackage>,
pub startover_window_seconds: Option<i64>,
pub time_delay_seconds: Option<i64>,
pub whitelist: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct OriginEndpointList {
pub next_token: Option<String>,
pub origin_endpoints: Option<Vec<OriginEndpoint>>,
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct OriginEndpointUpdateParameters {
pub cmaf_package: Option<CmafPackageCreateOrUpdateParameters>,
pub dash_package: Option<DashPackage>,
pub description: Option<String>,
pub hls_package: Option<HlsPackage>,
pub manifest_name: Option<String>,
pub mss_package: Option<MssPackage>,
pub startover_window_seconds: Option<i64>,
pub time_delay_seconds: Option<i64>,
pub whitelist: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RotateChannelCredentialsRequest {
#[serde(rename = "Id")]
pub id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct RotateChannelCredentialsResponse {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsIngest")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_ingest: Option<HlsIngest>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RotateIngestEndpointCredentialsRequest {
#[serde(rename = "Id")]
pub id: String,
#[serde(rename = "IngestEndpointId")]
pub ingest_endpoint_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct RotateIngestEndpointCredentialsResponse {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsIngest")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_ingest: Option<HlsIngest>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SpekeKeyProvider {
#[serde(rename = "CertificateArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate_arn: Option<String>,
#[serde(rename = "ResourceId")]
pub resource_id: String,
#[serde(rename = "RoleArn")]
pub role_arn: String,
#[serde(rename = "SystemIds")]
pub system_ids: Vec<String>,
#[serde(rename = "Url")]
pub url: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct StreamSelection {
#[serde(rename = "MaxVideoBitsPerSecond")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_video_bits_per_second: Option<i64>,
#[serde(rename = "MinVideoBitsPerSecond")]
#[serde(skip_serializing_if = "Option::is_none")]
pub min_video_bits_per_second: Option<i64>,
#[serde(rename = "StreamOrder")]
#[serde(skip_serializing_if = "Option::is_none")]
pub stream_order: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateChannelRequest {
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Id")]
pub id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateChannelResponse {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsIngest")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_ingest: Option<HlsIngest>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateOriginEndpointRequest {
#[serde(rename = "CmafPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cmaf_package: Option<CmafPackageCreateOrUpdateParameters>,
#[serde(rename = "DashPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_package: Option<DashPackage>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_package: Option<HlsPackage>,
#[serde(rename = "Id")]
pub id: String,
#[serde(rename = "ManifestName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_name: Option<String>,
#[serde(rename = "MssPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mss_package: Option<MssPackage>,
#[serde(rename = "StartoverWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub startover_window_seconds: Option<i64>,
#[serde(rename = "TimeDelaySeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_delay_seconds: Option<i64>,
#[serde(rename = "Whitelist")]
#[serde(skip_serializing_if = "Option::is_none")]
pub whitelist: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateOriginEndpointResponse {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "ChannelId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
#[serde(rename = "CmafPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cmaf_package: Option<CmafPackage>,
#[serde(rename = "DashPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_package: Option<DashPackage>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "HlsPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_package: Option<HlsPackage>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "ManifestName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_name: Option<String>,
#[serde(rename = "MssPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mss_package: Option<MssPackage>,
#[serde(rename = "StartoverWindowSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub startover_window_seconds: Option<i64>,
#[serde(rename = "TimeDelaySeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_delay_seconds: Option<i64>,
#[serde(rename = "Url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(rename = "Whitelist")]
#[serde(skip_serializing_if = "Option::is_none")]
pub whitelist: Option<Vec<String>>,
}
#[derive(Debug, PartialEq)]
pub enum CreateChannelError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateChannelError {
pub fn from_response(res: BufferedHttpResponse) -> CreateChannelError {
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 {
"ForbiddenException" => {
return CreateChannelError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return CreateChannelError::InternalServerError(String::from(error_message));
}
"NotFoundException" => {
return CreateChannelError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return CreateChannelError::ServiceUnavailable(String::from(error_message));
}
"TooManyRequestsException" => {
return CreateChannelError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return CreateChannelError::UnprocessableEntity(String::from(error_message));
}
"ValidationException" => {
return CreateChannelError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateChannelError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateChannelError {
fn from(err: serde_json::error::Error) -> CreateChannelError {
CreateChannelError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateChannelError {
fn from(err: CredentialsError) -> CreateChannelError {
CreateChannelError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateChannelError {
fn from(err: HttpDispatchError) -> CreateChannelError {
CreateChannelError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateChannelError {
fn from(err: io::Error) -> CreateChannelError {
CreateChannelError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateChannelError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateChannelError {
fn description(&self) -> &str {
match *self {
CreateChannelError::Forbidden(ref cause) => cause,
CreateChannelError::InternalServerError(ref cause) => cause,
CreateChannelError::NotFound(ref cause) => cause,
CreateChannelError::ServiceUnavailable(ref cause) => cause,
CreateChannelError::TooManyRequests(ref cause) => cause,
CreateChannelError::UnprocessableEntity(ref cause) => cause,
CreateChannelError::Validation(ref cause) => cause,
CreateChannelError::Credentials(ref err) => err.description(),
CreateChannelError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateChannelError::ParseError(ref cause) => cause,
CreateChannelError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateOriginEndpointError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateOriginEndpointError {
pub fn from_response(res: BufferedHttpResponse) -> CreateOriginEndpointError {
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 {
"ForbiddenException" => {
return CreateOriginEndpointError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return CreateOriginEndpointError::InternalServerError(String::from(
error_message,
));
}
"NotFoundException" => {
return CreateOriginEndpointError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return CreateOriginEndpointError::ServiceUnavailable(String::from(
error_message,
));
}
"TooManyRequestsException" => {
return CreateOriginEndpointError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return CreateOriginEndpointError::UnprocessableEntity(String::from(
error_message,
));
}
"ValidationException" => {
return CreateOriginEndpointError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateOriginEndpointError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateOriginEndpointError {
fn from(err: serde_json::error::Error) -> CreateOriginEndpointError {
CreateOriginEndpointError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateOriginEndpointError {
fn from(err: CredentialsError) -> CreateOriginEndpointError {
CreateOriginEndpointError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateOriginEndpointError {
fn from(err: HttpDispatchError) -> CreateOriginEndpointError {
CreateOriginEndpointError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateOriginEndpointError {
fn from(err: io::Error) -> CreateOriginEndpointError {
CreateOriginEndpointError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateOriginEndpointError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateOriginEndpointError {
fn description(&self) -> &str {
match *self {
CreateOriginEndpointError::Forbidden(ref cause) => cause,
CreateOriginEndpointError::InternalServerError(ref cause) => cause,
CreateOriginEndpointError::NotFound(ref cause) => cause,
CreateOriginEndpointError::ServiceUnavailable(ref cause) => cause,
CreateOriginEndpointError::TooManyRequests(ref cause) => cause,
CreateOriginEndpointError::UnprocessableEntity(ref cause) => cause,
CreateOriginEndpointError::Validation(ref cause) => cause,
CreateOriginEndpointError::Credentials(ref err) => err.description(),
CreateOriginEndpointError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
CreateOriginEndpointError::ParseError(ref cause) => cause,
CreateOriginEndpointError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteChannelError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteChannelError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteChannelError {
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 {
"ForbiddenException" => {
return DeleteChannelError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return DeleteChannelError::InternalServerError(String::from(error_message));
}
"NotFoundException" => {
return DeleteChannelError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return DeleteChannelError::ServiceUnavailable(String::from(error_message));
}
"TooManyRequestsException" => {
return DeleteChannelError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return DeleteChannelError::UnprocessableEntity(String::from(error_message));
}
"ValidationException" => {
return DeleteChannelError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteChannelError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteChannelError {
fn from(err: serde_json::error::Error) -> DeleteChannelError {
DeleteChannelError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteChannelError {
fn from(err: CredentialsError) -> DeleteChannelError {
DeleteChannelError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteChannelError {
fn from(err: HttpDispatchError) -> DeleteChannelError {
DeleteChannelError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteChannelError {
fn from(err: io::Error) -> DeleteChannelError {
DeleteChannelError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteChannelError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteChannelError {
fn description(&self) -> &str {
match *self {
DeleteChannelError::Forbidden(ref cause) => cause,
DeleteChannelError::InternalServerError(ref cause) => cause,
DeleteChannelError::NotFound(ref cause) => cause,
DeleteChannelError::ServiceUnavailable(ref cause) => cause,
DeleteChannelError::TooManyRequests(ref cause) => cause,
DeleteChannelError::UnprocessableEntity(ref cause) => cause,
DeleteChannelError::Validation(ref cause) => cause,
DeleteChannelError::Credentials(ref err) => err.description(),
DeleteChannelError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteChannelError::ParseError(ref cause) => cause,
DeleteChannelError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteOriginEndpointError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteOriginEndpointError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteOriginEndpointError {
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 {
"ForbiddenException" => {
return DeleteOriginEndpointError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return DeleteOriginEndpointError::InternalServerError(String::from(
error_message,
));
}
"NotFoundException" => {
return DeleteOriginEndpointError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return DeleteOriginEndpointError::ServiceUnavailable(String::from(
error_message,
));
}
"TooManyRequestsException" => {
return DeleteOriginEndpointError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return DeleteOriginEndpointError::UnprocessableEntity(String::from(
error_message,
));
}
"ValidationException" => {
return DeleteOriginEndpointError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteOriginEndpointError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteOriginEndpointError {
fn from(err: serde_json::error::Error) -> DeleteOriginEndpointError {
DeleteOriginEndpointError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteOriginEndpointError {
fn from(err: CredentialsError) -> DeleteOriginEndpointError {
DeleteOriginEndpointError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteOriginEndpointError {
fn from(err: HttpDispatchError) -> DeleteOriginEndpointError {
DeleteOriginEndpointError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteOriginEndpointError {
fn from(err: io::Error) -> DeleteOriginEndpointError {
DeleteOriginEndpointError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteOriginEndpointError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteOriginEndpointError {
fn description(&self) -> &str {
match *self {
DeleteOriginEndpointError::Forbidden(ref cause) => cause,
DeleteOriginEndpointError::InternalServerError(ref cause) => cause,
DeleteOriginEndpointError::NotFound(ref cause) => cause,
DeleteOriginEndpointError::ServiceUnavailable(ref cause) => cause,
DeleteOriginEndpointError::TooManyRequests(ref cause) => cause,
DeleteOriginEndpointError::UnprocessableEntity(ref cause) => cause,
DeleteOriginEndpointError::Validation(ref cause) => cause,
DeleteOriginEndpointError::Credentials(ref err) => err.description(),
DeleteOriginEndpointError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DeleteOriginEndpointError::ParseError(ref cause) => cause,
DeleteOriginEndpointError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeChannelError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeChannelError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeChannelError {
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 {
"ForbiddenException" => {
return DescribeChannelError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return DescribeChannelError::InternalServerError(String::from(error_message));
}
"NotFoundException" => {
return DescribeChannelError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return DescribeChannelError::ServiceUnavailable(String::from(error_message));
}
"TooManyRequestsException" => {
return DescribeChannelError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return DescribeChannelError::UnprocessableEntity(String::from(error_message));
}
"ValidationException" => {
return DescribeChannelError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeChannelError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeChannelError {
fn from(err: serde_json::error::Error) -> DescribeChannelError {
DescribeChannelError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeChannelError {
fn from(err: CredentialsError) -> DescribeChannelError {
DescribeChannelError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeChannelError {
fn from(err: HttpDispatchError) -> DescribeChannelError {
DescribeChannelError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeChannelError {
fn from(err: io::Error) -> DescribeChannelError {
DescribeChannelError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeChannelError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeChannelError {
fn description(&self) -> &str {
match *self {
DescribeChannelError::Forbidden(ref cause) => cause,
DescribeChannelError::InternalServerError(ref cause) => cause,
DescribeChannelError::NotFound(ref cause) => cause,
DescribeChannelError::ServiceUnavailable(ref cause) => cause,
DescribeChannelError::TooManyRequests(ref cause) => cause,
DescribeChannelError::UnprocessableEntity(ref cause) => cause,
DescribeChannelError::Validation(ref cause) => cause,
DescribeChannelError::Credentials(ref err) => err.description(),
DescribeChannelError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeChannelError::ParseError(ref cause) => cause,
DescribeChannelError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeOriginEndpointError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeOriginEndpointError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeOriginEndpointError {
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 {
"ForbiddenException" => {
return DescribeOriginEndpointError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return DescribeOriginEndpointError::InternalServerError(String::from(
error_message,
));
}
"NotFoundException" => {
return DescribeOriginEndpointError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return DescribeOriginEndpointError::ServiceUnavailable(String::from(
error_message,
));
}
"TooManyRequestsException" => {
return DescribeOriginEndpointError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return DescribeOriginEndpointError::UnprocessableEntity(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeOriginEndpointError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeOriginEndpointError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeOriginEndpointError {
fn from(err: serde_json::error::Error) -> DescribeOriginEndpointError {
DescribeOriginEndpointError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeOriginEndpointError {
fn from(err: CredentialsError) -> DescribeOriginEndpointError {
DescribeOriginEndpointError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeOriginEndpointError {
fn from(err: HttpDispatchError) -> DescribeOriginEndpointError {
DescribeOriginEndpointError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeOriginEndpointError {
fn from(err: io::Error) -> DescribeOriginEndpointError {
DescribeOriginEndpointError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeOriginEndpointError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeOriginEndpointError {
fn description(&self) -> &str {
match *self {
DescribeOriginEndpointError::Forbidden(ref cause) => cause,
DescribeOriginEndpointError::InternalServerError(ref cause) => cause,
DescribeOriginEndpointError::NotFound(ref cause) => cause,
DescribeOriginEndpointError::ServiceUnavailable(ref cause) => cause,
DescribeOriginEndpointError::TooManyRequests(ref cause) => cause,
DescribeOriginEndpointError::UnprocessableEntity(ref cause) => cause,
DescribeOriginEndpointError::Validation(ref cause) => cause,
DescribeOriginEndpointError::Credentials(ref err) => err.description(),
DescribeOriginEndpointError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeOriginEndpointError::ParseError(ref cause) => cause,
DescribeOriginEndpointError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListChannelsError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListChannelsError {
pub fn from_response(res: BufferedHttpResponse) -> ListChannelsError {
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 {
"ForbiddenException" => {
return ListChannelsError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return ListChannelsError::InternalServerError(String::from(error_message));
}
"NotFoundException" => {
return ListChannelsError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return ListChannelsError::ServiceUnavailable(String::from(error_message));
}
"TooManyRequestsException" => {
return ListChannelsError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return ListChannelsError::UnprocessableEntity(String::from(error_message));
}
"ValidationException" => {
return ListChannelsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListChannelsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListChannelsError {
fn from(err: serde_json::error::Error) -> ListChannelsError {
ListChannelsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListChannelsError {
fn from(err: CredentialsError) -> ListChannelsError {
ListChannelsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListChannelsError {
fn from(err: HttpDispatchError) -> ListChannelsError {
ListChannelsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListChannelsError {
fn from(err: io::Error) -> ListChannelsError {
ListChannelsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListChannelsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListChannelsError {
fn description(&self) -> &str {
match *self {
ListChannelsError::Forbidden(ref cause) => cause,
ListChannelsError::InternalServerError(ref cause) => cause,
ListChannelsError::NotFound(ref cause) => cause,
ListChannelsError::ServiceUnavailable(ref cause) => cause,
ListChannelsError::TooManyRequests(ref cause) => cause,
ListChannelsError::UnprocessableEntity(ref cause) => cause,
ListChannelsError::Validation(ref cause) => cause,
ListChannelsError::Credentials(ref err) => err.description(),
ListChannelsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListChannelsError::ParseError(ref cause) => cause,
ListChannelsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListOriginEndpointsError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListOriginEndpointsError {
pub fn from_response(res: BufferedHttpResponse) -> ListOriginEndpointsError {
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 {
"ForbiddenException" => {
return ListOriginEndpointsError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return ListOriginEndpointsError::InternalServerError(String::from(
error_message,
));
}
"NotFoundException" => {
return ListOriginEndpointsError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return ListOriginEndpointsError::ServiceUnavailable(String::from(error_message));
}
"TooManyRequestsException" => {
return ListOriginEndpointsError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return ListOriginEndpointsError::UnprocessableEntity(String::from(
error_message,
));
}
"ValidationException" => {
return ListOriginEndpointsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListOriginEndpointsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListOriginEndpointsError {
fn from(err: serde_json::error::Error) -> ListOriginEndpointsError {
ListOriginEndpointsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListOriginEndpointsError {
fn from(err: CredentialsError) -> ListOriginEndpointsError {
ListOriginEndpointsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListOriginEndpointsError {
fn from(err: HttpDispatchError) -> ListOriginEndpointsError {
ListOriginEndpointsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListOriginEndpointsError {
fn from(err: io::Error) -> ListOriginEndpointsError {
ListOriginEndpointsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListOriginEndpointsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListOriginEndpointsError {
fn description(&self) -> &str {
match *self {
ListOriginEndpointsError::Forbidden(ref cause) => cause,
ListOriginEndpointsError::InternalServerError(ref cause) => cause,
ListOriginEndpointsError::NotFound(ref cause) => cause,
ListOriginEndpointsError::ServiceUnavailable(ref cause) => cause,
ListOriginEndpointsError::TooManyRequests(ref cause) => cause,
ListOriginEndpointsError::UnprocessableEntity(ref cause) => cause,
ListOriginEndpointsError::Validation(ref cause) => cause,
ListOriginEndpointsError::Credentials(ref err) => err.description(),
ListOriginEndpointsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListOriginEndpointsError::ParseError(ref cause) => cause,
ListOriginEndpointsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum RotateChannelCredentialsError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl RotateChannelCredentialsError {
pub fn from_response(res: BufferedHttpResponse) -> RotateChannelCredentialsError {
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 {
"ForbiddenException" => {
return RotateChannelCredentialsError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return RotateChannelCredentialsError::InternalServerError(String::from(
error_message,
));
}
"NotFoundException" => {
return RotateChannelCredentialsError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return RotateChannelCredentialsError::ServiceUnavailable(String::from(
error_message,
));
}
"TooManyRequestsException" => {
return RotateChannelCredentialsError::TooManyRequests(String::from(
error_message,
));
}
"UnprocessableEntityException" => {
return RotateChannelCredentialsError::UnprocessableEntity(String::from(
error_message,
));
}
"ValidationException" => {
return RotateChannelCredentialsError::Validation(error_message.to_string());
}
_ => {}
}
}
return RotateChannelCredentialsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for RotateChannelCredentialsError {
fn from(err: serde_json::error::Error) -> RotateChannelCredentialsError {
RotateChannelCredentialsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for RotateChannelCredentialsError {
fn from(err: CredentialsError) -> RotateChannelCredentialsError {
RotateChannelCredentialsError::Credentials(err)
}
}
impl From<HttpDispatchError> for RotateChannelCredentialsError {
fn from(err: HttpDispatchError) -> RotateChannelCredentialsError {
RotateChannelCredentialsError::HttpDispatch(err)
}
}
impl From<io::Error> for RotateChannelCredentialsError {
fn from(err: io::Error) -> RotateChannelCredentialsError {
RotateChannelCredentialsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for RotateChannelCredentialsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RotateChannelCredentialsError {
fn description(&self) -> &str {
match *self {
RotateChannelCredentialsError::Forbidden(ref cause) => cause,
RotateChannelCredentialsError::InternalServerError(ref cause) => cause,
RotateChannelCredentialsError::NotFound(ref cause) => cause,
RotateChannelCredentialsError::ServiceUnavailable(ref cause) => cause,
RotateChannelCredentialsError::TooManyRequests(ref cause) => cause,
RotateChannelCredentialsError::UnprocessableEntity(ref cause) => cause,
RotateChannelCredentialsError::Validation(ref cause) => cause,
RotateChannelCredentialsError::Credentials(ref err) => err.description(),
RotateChannelCredentialsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
RotateChannelCredentialsError::ParseError(ref cause) => cause,
RotateChannelCredentialsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum RotateIngestEndpointCredentialsError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl RotateIngestEndpointCredentialsError {
pub fn from_response(res: BufferedHttpResponse) -> RotateIngestEndpointCredentialsError {
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 {
"ForbiddenException" => {
return RotateIngestEndpointCredentialsError::Forbidden(String::from(
error_message,
));
}
"InternalServerErrorException" => {
return RotateIngestEndpointCredentialsError::InternalServerError(String::from(
error_message,
));
}
"NotFoundException" => {
return RotateIngestEndpointCredentialsError::NotFound(String::from(
error_message,
));
}
"ServiceUnavailableException" => {
return RotateIngestEndpointCredentialsError::ServiceUnavailable(String::from(
error_message,
));
}
"TooManyRequestsException" => {
return RotateIngestEndpointCredentialsError::TooManyRequests(String::from(
error_message,
));
}
"UnprocessableEntityException" => {
return RotateIngestEndpointCredentialsError::UnprocessableEntity(String::from(
error_message,
));
}
"ValidationException" => {
return RotateIngestEndpointCredentialsError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return RotateIngestEndpointCredentialsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for RotateIngestEndpointCredentialsError {
fn from(err: serde_json::error::Error) -> RotateIngestEndpointCredentialsError {
RotateIngestEndpointCredentialsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for RotateIngestEndpointCredentialsError {
fn from(err: CredentialsError) -> RotateIngestEndpointCredentialsError {
RotateIngestEndpointCredentialsError::Credentials(err)
}
}
impl From<HttpDispatchError> for RotateIngestEndpointCredentialsError {
fn from(err: HttpDispatchError) -> RotateIngestEndpointCredentialsError {
RotateIngestEndpointCredentialsError::HttpDispatch(err)
}
}
impl From<io::Error> for RotateIngestEndpointCredentialsError {
fn from(err: io::Error) -> RotateIngestEndpointCredentialsError {
RotateIngestEndpointCredentialsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for RotateIngestEndpointCredentialsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RotateIngestEndpointCredentialsError {
fn description(&self) -> &str {
match *self {
RotateIngestEndpointCredentialsError::Forbidden(ref cause) => cause,
RotateIngestEndpointCredentialsError::InternalServerError(ref cause) => cause,
RotateIngestEndpointCredentialsError::NotFound(ref cause) => cause,
RotateIngestEndpointCredentialsError::ServiceUnavailable(ref cause) => cause,
RotateIngestEndpointCredentialsError::TooManyRequests(ref cause) => cause,
RotateIngestEndpointCredentialsError::UnprocessableEntity(ref cause) => cause,
RotateIngestEndpointCredentialsError::Validation(ref cause) => cause,
RotateIngestEndpointCredentialsError::Credentials(ref err) => err.description(),
RotateIngestEndpointCredentialsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
RotateIngestEndpointCredentialsError::ParseError(ref cause) => cause,
RotateIngestEndpointCredentialsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateChannelError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateChannelError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateChannelError {
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 {
"ForbiddenException" => {
return UpdateChannelError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return UpdateChannelError::InternalServerError(String::from(error_message));
}
"NotFoundException" => {
return UpdateChannelError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return UpdateChannelError::ServiceUnavailable(String::from(error_message));
}
"TooManyRequestsException" => {
return UpdateChannelError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return UpdateChannelError::UnprocessableEntity(String::from(error_message));
}
"ValidationException" => {
return UpdateChannelError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateChannelError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateChannelError {
fn from(err: serde_json::error::Error) -> UpdateChannelError {
UpdateChannelError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateChannelError {
fn from(err: CredentialsError) -> UpdateChannelError {
UpdateChannelError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateChannelError {
fn from(err: HttpDispatchError) -> UpdateChannelError {
UpdateChannelError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateChannelError {
fn from(err: io::Error) -> UpdateChannelError {
UpdateChannelError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateChannelError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateChannelError {
fn description(&self) -> &str {
match *self {
UpdateChannelError::Forbidden(ref cause) => cause,
UpdateChannelError::InternalServerError(ref cause) => cause,
UpdateChannelError::NotFound(ref cause) => cause,
UpdateChannelError::ServiceUnavailable(ref cause) => cause,
UpdateChannelError::TooManyRequests(ref cause) => cause,
UpdateChannelError::UnprocessableEntity(ref cause) => cause,
UpdateChannelError::Validation(ref cause) => cause,
UpdateChannelError::Credentials(ref err) => err.description(),
UpdateChannelError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
UpdateChannelError::ParseError(ref cause) => cause,
UpdateChannelError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateOriginEndpointError {
Forbidden(String),
InternalServerError(String),
NotFound(String),
ServiceUnavailable(String),
TooManyRequests(String),
UnprocessableEntity(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateOriginEndpointError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateOriginEndpointError {
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 {
"ForbiddenException" => {
return UpdateOriginEndpointError::Forbidden(String::from(error_message));
}
"InternalServerErrorException" => {
return UpdateOriginEndpointError::InternalServerError(String::from(
error_message,
));
}
"NotFoundException" => {
return UpdateOriginEndpointError::NotFound(String::from(error_message));
}
"ServiceUnavailableException" => {
return UpdateOriginEndpointError::ServiceUnavailable(String::from(
error_message,
));
}
"TooManyRequestsException" => {
return UpdateOriginEndpointError::TooManyRequests(String::from(error_message));
}
"UnprocessableEntityException" => {
return UpdateOriginEndpointError::UnprocessableEntity(String::from(
error_message,
));
}
"ValidationException" => {
return UpdateOriginEndpointError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateOriginEndpointError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateOriginEndpointError {
fn from(err: serde_json::error::Error) -> UpdateOriginEndpointError {
UpdateOriginEndpointError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateOriginEndpointError {
fn from(err: CredentialsError) -> UpdateOriginEndpointError {
UpdateOriginEndpointError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateOriginEndpointError {
fn from(err: HttpDispatchError) -> UpdateOriginEndpointError {
UpdateOriginEndpointError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateOriginEndpointError {
fn from(err: io::Error) -> UpdateOriginEndpointError {
UpdateOriginEndpointError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateOriginEndpointError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateOriginEndpointError {
fn description(&self) -> &str {
match *self {
UpdateOriginEndpointError::Forbidden(ref cause) => cause,
UpdateOriginEndpointError::InternalServerError(ref cause) => cause,
UpdateOriginEndpointError::NotFound(ref cause) => cause,
UpdateOriginEndpointError::ServiceUnavailable(ref cause) => cause,
UpdateOriginEndpointError::TooManyRequests(ref cause) => cause,
UpdateOriginEndpointError::UnprocessableEntity(ref cause) => cause,
UpdateOriginEndpointError::Validation(ref cause) => cause,
UpdateOriginEndpointError::Credentials(ref err) => err.description(),
UpdateOriginEndpointError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateOriginEndpointError::ParseError(ref cause) => cause,
UpdateOriginEndpointError::Unknown(_) => "unknown error",
}
}
}
pub trait MediaPackage {
fn create_channel(
&self,
input: CreateChannelRequest,
) -> RusotoFuture<CreateChannelResponse, CreateChannelError>;
fn create_origin_endpoint(
&self,
input: CreateOriginEndpointRequest,
) -> RusotoFuture<CreateOriginEndpointResponse, CreateOriginEndpointError>;
fn delete_channel(
&self,
input: DeleteChannelRequest,
) -> RusotoFuture<DeleteChannelResponse, DeleteChannelError>;
fn delete_origin_endpoint(
&self,
input: DeleteOriginEndpointRequest,
) -> RusotoFuture<DeleteOriginEndpointResponse, DeleteOriginEndpointError>;
fn describe_channel(
&self,
input: DescribeChannelRequest,
) -> RusotoFuture<DescribeChannelResponse, DescribeChannelError>;
fn describe_origin_endpoint(
&self,
input: DescribeOriginEndpointRequest,
) -> RusotoFuture<DescribeOriginEndpointResponse, DescribeOriginEndpointError>;
fn list_channels(
&self,
input: ListChannelsRequest,
) -> RusotoFuture<ListChannelsResponse, ListChannelsError>;
fn list_origin_endpoints(
&self,
input: ListOriginEndpointsRequest,
) -> RusotoFuture<ListOriginEndpointsResponse, ListOriginEndpointsError>;
fn rotate_channel_credentials(
&self,
input: RotateChannelCredentialsRequest,
) -> RusotoFuture<RotateChannelCredentialsResponse, RotateChannelCredentialsError>;
fn rotate_ingest_endpoint_credentials(
&self,
input: RotateIngestEndpointCredentialsRequest,
) -> RusotoFuture<RotateIngestEndpointCredentialsResponse, RotateIngestEndpointCredentialsError>;
fn update_channel(
&self,
input: UpdateChannelRequest,
) -> RusotoFuture<UpdateChannelResponse, UpdateChannelError>;
fn update_origin_endpoint(
&self,
input: UpdateOriginEndpointRequest,
) -> RusotoFuture<UpdateOriginEndpointResponse, UpdateOriginEndpointError>;
}
#[derive(Clone)]
pub struct MediaPackageClient {
client: Client,
region: region::Region,
}
impl MediaPackageClient {
pub fn new(region: region::Region) -> MediaPackageClient {
MediaPackageClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> MediaPackageClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
MediaPackageClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl MediaPackage for MediaPackageClient {
fn create_channel(
&self,
input: CreateChannelRequest,
) -> RusotoFuture<CreateChannelResponse, CreateChannelError> {
let request_uri = "/channels";
let mut request = SignedRequest::new("POST", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
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::<CreateChannelResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateChannelError::from_response(response))),
)
}
})
}
fn create_origin_endpoint(
&self,
input: CreateOriginEndpointRequest,
) -> RusotoFuture<CreateOriginEndpointResponse, CreateOriginEndpointError> {
let request_uri = "/origin_endpoints";
let mut request = SignedRequest::new("POST", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
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::<CreateOriginEndpointResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(CreateOriginEndpointError::from_response(response))
}),
)
}
})
}
fn delete_channel(
&self,
input: DeleteChannelRequest,
) -> RusotoFuture<DeleteChannelResponse, DeleteChannelError> {
let request_uri = format!("/channels/{id}", id = input.id);
let mut request = SignedRequest::new("DELETE", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 202 {
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::<DeleteChannelResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteChannelError::from_response(response))),
)
}
})
}
fn delete_origin_endpoint(
&self,
input: DeleteOriginEndpointRequest,
) -> RusotoFuture<DeleteOriginEndpointResponse, DeleteOriginEndpointError> {
let request_uri = format!("/origin_endpoints/{id}", id = input.id);
let mut request = SignedRequest::new("DELETE", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 202 {
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::<DeleteOriginEndpointResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DeleteOriginEndpointError::from_response(response))
}),
)
}
})
}
fn describe_channel(
&self,
input: DescribeChannelRequest,
) -> RusotoFuture<DescribeChannelResponse, DescribeChannelError> {
let request_uri = format!("/channels/{id}", id = input.id);
let mut request = SignedRequest::new("GET", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
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::<DescribeChannelResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeChannelError::from_response(response))),
)
}
})
}
fn describe_origin_endpoint(
&self,
input: DescribeOriginEndpointRequest,
) -> RusotoFuture<DescribeOriginEndpointResponse, DescribeOriginEndpointError> {
let request_uri = format!("/origin_endpoints/{id}", id = input.id);
let mut request = SignedRequest::new("GET", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
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::<DescribeOriginEndpointResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DescribeOriginEndpointError::from_response(response))
}),
)
}
})
}
fn list_channels(
&self,
input: ListChannelsRequest,
) -> RusotoFuture<ListChannelsResponse, ListChannelsError> {
let request_uri = "/channels";
let mut request = SignedRequest::new("GET", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
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.as_u16() == 200 {
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::<ListChannelsResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListChannelsError::from_response(response))),
)
}
})
}
fn list_origin_endpoints(
&self,
input: ListOriginEndpointsRequest,
) -> RusotoFuture<ListOriginEndpointsResponse, ListOriginEndpointsError> {
let request_uri = "/origin_endpoints";
let mut request = SignedRequest::new("GET", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.channel_id {
params.put("channelId", 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().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::<ListOriginEndpointsResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(ListOriginEndpointsError::from_response(response))
}),
)
}
})
}
fn rotate_channel_credentials(
&self,
input: RotateChannelCredentialsRequest,
) -> RusotoFuture<RotateChannelCredentialsResponse, RotateChannelCredentialsError> {
let request_uri = format!("/channels/{id}/credentials", id = input.id);
let mut request = SignedRequest::new("PUT", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
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::<RotateChannelCredentialsResponse>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(RotateChannelCredentialsError::from_response(response))
}))
}
})
}
fn rotate_ingest_endpoint_credentials(
&self,
input: RotateIngestEndpointCredentialsRequest,
) -> RusotoFuture<RotateIngestEndpointCredentialsResponse, RotateIngestEndpointCredentialsError>
{
let request_uri = format!(
"/channels/{id}/ingest_endpoints/{ingest_endpoint_id}/credentials",
id = input.id,
ingest_endpoint_id = input.ingest_endpoint_id
);
let mut request = SignedRequest::new("PUT", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
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::<RotateIngestEndpointCredentialsResponse>(&body)
.unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(RotateIngestEndpointCredentialsError::from_response(
response,
))
}))
}
})
}
fn update_channel(
&self,
input: UpdateChannelRequest,
) -> RusotoFuture<UpdateChannelResponse, UpdateChannelError> {
let request_uri = format!("/channels/{id}", id = input.id);
let mut request = SignedRequest::new("PUT", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
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::<UpdateChannelResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateChannelError::from_response(response))),
)
}
})
}
fn update_origin_endpoint(
&self,
input: UpdateOriginEndpointRequest,
) -> RusotoFuture<UpdateOriginEndpointResponse, UpdateOriginEndpointError> {
let request_uri = format!("/origin_endpoints/{id}", id = input.id);
let mut request = SignedRequest::new("PUT", "mediapackage", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
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::<UpdateOriginEndpointResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(UpdateOriginEndpointError::from_response(response))
}),
)
}
})
}
}
#[cfg(test)]
mod protocol_tests {}