use std::error::Error;
use std::fmt;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError, RusotoFuture};
use rusoto_core::param::{Params, ServiceParams};
use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
use serde_json;
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CdnConfiguration {
#[serde(rename = "AdSegmentUrlPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ad_segment_url_prefix: Option<String>,
#[serde(rename = "ContentSegmentUrlPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_segment_url_prefix: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DashConfiguration {
#[serde(rename = "ManifestEndpointPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_endpoint_prefix: Option<String>,
#[serde(rename = "MpdLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mpd_location: Option<String>,
#[serde(rename = "OriginManifestType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub origin_manifest_type: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DashConfigurationForPut {
#[serde(rename = "MpdLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mpd_location: Option<String>,
#[serde(rename = "OriginManifestType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub origin_manifest_type: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeletePlaybackConfigurationRequest {
#[serde(rename = "Name")]
pub name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeletePlaybackConfigurationResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetPlaybackConfigurationRequest {
#[serde(rename = "Name")]
pub name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetPlaybackConfigurationResponse {
#[serde(rename = "AdDecisionServerUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ad_decision_server_url: Option<String>,
#[serde(rename = "CdnConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cdn_configuration: Option<CdnConfiguration>,
#[serde(rename = "DashConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_configuration: Option<DashConfiguration>,
#[serde(rename = "HlsConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_configuration: Option<HlsConfiguration>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "PlaybackConfigurationArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playback_configuration_arn: Option<String>,
#[serde(rename = "PlaybackEndpointPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playback_endpoint_prefix: Option<String>,
#[serde(rename = "SessionInitializationEndpointPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub session_initialization_endpoint_prefix: Option<String>,
#[serde(rename = "SlateAdUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub slate_ad_url: Option<String>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "TranscodeProfileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcode_profile_name: Option<String>,
#[serde(rename = "VideoContentSourceUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub video_content_source_url: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct HlsConfiguration {
#[serde(rename = "ManifestEndpointPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_endpoint_prefix: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListPlaybackConfigurationsRequest {
#[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 ListPlaybackConfigurationsResponse {
#[serde(rename = "Items")]
#[serde(skip_serializing_if = "Option::is_none")]
pub items: Option<Vec<PlaybackConfiguration>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListTagsForResourceRequest {
#[serde(rename = "ResourceArn")]
pub resource_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListTagsForResourceResponse {
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PlaybackConfiguration {
#[serde(rename = "AdDecisionServerUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ad_decision_server_url: Option<String>,
#[serde(rename = "CdnConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cdn_configuration: Option<CdnConfiguration>,
#[serde(rename = "DashConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_configuration: Option<DashConfiguration>,
#[serde(rename = "HlsConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_configuration: Option<HlsConfiguration>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "PlaybackConfigurationArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playback_configuration_arn: Option<String>,
#[serde(rename = "PlaybackEndpointPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playback_endpoint_prefix: Option<String>,
#[serde(rename = "SessionInitializationEndpointPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub session_initialization_endpoint_prefix: Option<String>,
#[serde(rename = "SlateAdUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub slate_ad_url: Option<String>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "TranscodeProfileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcode_profile_name: Option<String>,
#[serde(rename = "VideoContentSourceUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub video_content_source_url: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutPlaybackConfigurationRequest {
#[serde(rename = "AdDecisionServerUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ad_decision_server_url: Option<String>,
#[serde(rename = "CdnConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cdn_configuration: Option<CdnConfiguration>,
#[serde(rename = "DashConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_configuration: Option<DashConfigurationForPut>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "SlateAdUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub slate_ad_url: Option<String>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "TranscodeProfileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcode_profile_name: Option<String>,
#[serde(rename = "VideoContentSourceUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub video_content_source_url: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PutPlaybackConfigurationResponse {
#[serde(rename = "AdDecisionServerUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ad_decision_server_url: Option<String>,
#[serde(rename = "CdnConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cdn_configuration: Option<CdnConfiguration>,
#[serde(rename = "DashConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dash_configuration: Option<DashConfiguration>,
#[serde(rename = "HlsConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hls_configuration: Option<HlsConfiguration>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "PlaybackConfigurationArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playback_configuration_arn: Option<String>,
#[serde(rename = "PlaybackEndpointPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub playback_endpoint_prefix: Option<String>,
#[serde(rename = "SessionInitializationEndpointPrefix")]
#[serde(skip_serializing_if = "Option::is_none")]
pub session_initialization_endpoint_prefix: Option<String>,
#[serde(rename = "SlateAdUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub slate_ad_url: Option<String>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "TranscodeProfileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transcode_profile_name: Option<String>,
#[serde(rename = "VideoContentSourceUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub video_content_source_url: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct TagResourceRequest {
#[serde(rename = "ResourceArn")]
pub resource_arn: String,
#[serde(rename = "Tags")]
pub tags: ::std::collections::HashMap<String, String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UntagResourceRequest {
#[serde(rename = "ResourceArn")]
pub resource_arn: String,
#[serde(rename = "TagKeys")]
pub tag_keys: Vec<String>,
}
#[derive(Debug, PartialEq)]
pub enum DeletePlaybackConfigurationError {}
impl DeletePlaybackConfigurationError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<DeletePlaybackConfigurationError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeletePlaybackConfigurationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeletePlaybackConfigurationError {
fn description(&self) -> &str {
match *self {}
}
}
#[derive(Debug, PartialEq)]
pub enum GetPlaybackConfigurationError {}
impl GetPlaybackConfigurationError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetPlaybackConfigurationError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetPlaybackConfigurationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetPlaybackConfigurationError {
fn description(&self) -> &str {
match *self {}
}
}
#[derive(Debug, PartialEq)]
pub enum ListPlaybackConfigurationsError {}
impl ListPlaybackConfigurationsError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<ListPlaybackConfigurationsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListPlaybackConfigurationsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListPlaybackConfigurationsError {
fn description(&self) -> &str {
match *self {}
}
}
#[derive(Debug, PartialEq)]
pub enum ListTagsForResourceError {
BadRequest(String),
}
impl ListTagsForResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListTagsForResourceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(ListTagsForResourceError::BadRequest(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListTagsForResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListTagsForResourceError {
fn description(&self) -> &str {
match *self {
ListTagsForResourceError::BadRequest(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutPlaybackConfigurationError {}
impl PutPlaybackConfigurationError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PutPlaybackConfigurationError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for PutPlaybackConfigurationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutPlaybackConfigurationError {
fn description(&self) -> &str {
match *self {}
}
}
#[derive(Debug, PartialEq)]
pub enum TagResourceError {
BadRequest(String),
}
impl TagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<TagResourceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(TagResourceError::BadRequest(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for TagResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for TagResourceError {
fn description(&self) -> &str {
match *self {
TagResourceError::BadRequest(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UntagResourceError {
BadRequest(String),
}
impl UntagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UntagResourceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"BadRequestException" => {
return RusotoError::Service(UntagResourceError::BadRequest(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for UntagResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UntagResourceError {
fn description(&self) -> &str {
match *self {
UntagResourceError::BadRequest(ref cause) => cause,
}
}
}
pub trait MediaTailor {
fn delete_playback_configuration(
&self,
input: DeletePlaybackConfigurationRequest,
) -> RusotoFuture<DeletePlaybackConfigurationResponse, DeletePlaybackConfigurationError>;
fn get_playback_configuration(
&self,
input: GetPlaybackConfigurationRequest,
) -> RusotoFuture<GetPlaybackConfigurationResponse, GetPlaybackConfigurationError>;
fn list_playback_configurations(
&self,
input: ListPlaybackConfigurationsRequest,
) -> RusotoFuture<ListPlaybackConfigurationsResponse, ListPlaybackConfigurationsError>;
fn list_tags_for_resource(
&self,
input: ListTagsForResourceRequest,
) -> RusotoFuture<ListTagsForResourceResponse, ListTagsForResourceError>;
fn put_playback_configuration(
&self,
input: PutPlaybackConfigurationRequest,
) -> RusotoFuture<PutPlaybackConfigurationResponse, PutPlaybackConfigurationError>;
fn tag_resource(&self, input: TagResourceRequest) -> RusotoFuture<(), TagResourceError>;
fn untag_resource(&self, input: UntagResourceRequest) -> RusotoFuture<(), UntagResourceError>;
}
#[derive(Clone)]
pub struct MediaTailorClient {
client: Client,
region: region::Region,
}
impl MediaTailorClient {
pub fn new(region: region::Region) -> MediaTailorClient {
MediaTailorClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> MediaTailorClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
MediaTailorClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl MediaTailor for MediaTailorClient {
fn delete_playback_configuration(
&self,
input: DeletePlaybackConfigurationRequest,
) -> RusotoFuture<DeletePlaybackConfigurationResponse, DeletePlaybackConfigurationError> {
let request_uri = format!("/playbackConfiguration/{name}", name = input.name);
let mut request = SignedRequest::new("DELETE", "mediatailor", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.mediatailor".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DeletePlaybackConfigurationResponse, _>()?;
Ok(result)
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DeletePlaybackConfigurationError::from_response(response))
}))
}
})
}
fn get_playback_configuration(
&self,
input: GetPlaybackConfigurationRequest,
) -> RusotoFuture<GetPlaybackConfigurationResponse, GetPlaybackConfigurationError> {
let request_uri = format!("/playbackConfiguration/{name}", name = input.name);
let mut request = SignedRequest::new("GET", "mediatailor", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.mediatailor".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<GetPlaybackConfigurationResponse, _>()?;
Ok(result)
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(GetPlaybackConfigurationError::from_response(response))
}))
}
})
}
fn list_playback_configurations(
&self,
input: ListPlaybackConfigurationsRequest,
) -> RusotoFuture<ListPlaybackConfigurationsResponse, ListPlaybackConfigurationsError> {
let request_uri = "/playbackConfigurations";
let mut request = SignedRequest::new("GET", "mediatailor", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.mediatailor".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.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListPlaybackConfigurationsResponse, _>()?;
Ok(result)
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ListPlaybackConfigurationsError::from_response(response))
}))
}
})
}
fn list_tags_for_resource(
&self,
input: ListTagsForResourceRequest,
) -> RusotoFuture<ListTagsForResourceResponse, ListTagsForResourceError> {
let request_uri = format!("/tags/{resource_arn}", resource_arn = input.resource_arn);
let mut request = SignedRequest::new("GET", "mediatailor", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.mediatailor".to_string());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListTagsForResourceResponse, _>()?;
Ok(result)
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(ListTagsForResourceError::from_response(response))
}),
)
}
})
}
fn put_playback_configuration(
&self,
input: PutPlaybackConfigurationRequest,
) -> RusotoFuture<PutPlaybackConfigurationResponse, PutPlaybackConfigurationError> {
let request_uri = "/playbackConfiguration";
let mut request = SignedRequest::new("PUT", "mediatailor", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.mediatailor".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<PutPlaybackConfigurationResponse, _>()?;
Ok(result)
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(PutPlaybackConfigurationError::from_response(response))
}))
}
})
}
fn tag_resource(&self, input: TagResourceRequest) -> RusotoFuture<(), TagResourceError> {
let request_uri = format!("/tags/{resource_arn}", resource_arn = input.resource_arn);
let mut request = SignedRequest::new("POST", "mediatailor", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.mediatailor".to_string());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = ::std::mem::drop(response);
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(TagResourceError::from_response(response))),
)
}
})
}
fn untag_resource(&self, input: UntagResourceRequest) -> RusotoFuture<(), UntagResourceError> {
let request_uri = format!("/tags/{resource_arn}", resource_arn = input.resource_arn);
let mut request = SignedRequest::new("DELETE", "mediatailor", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.set_endpoint_prefix("api.mediatailor".to_string());
let mut params = Params::new();
for item in input.tag_keys.iter() {
params.put("tagKeys", item);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().and_then(|response| {
let result = ::std::mem::drop(response);
Ok(result)
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UntagResourceError::from_response(response))),
)
}
})
}
}