Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Services MediaLive and MediaPackage #449

Merged
merged 7 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions aws/sdk/examples/medialive-helloworld/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "medialive-helloworld"
version = "0.1.0"
authors = ["Alistair McLean <mclean@amazon.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
medialive = { package = "aws-sdk-medialive", path = "../../build/aws-sdk/medialive" }
tokio = { version = "1", features = ["full"] }
# used only to enable basic logging:
env_logger = "0.8.2"
16 changes: 16 additions & 0 deletions aws/sdk/examples/medialive-helloworld/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#[tokio::main]
async fn main() -> Result<(), medialive::Error> {
let client = medialive::Client::from_env();
let input_list = client.list_inputs().send().await?;

if let Some(inputs) = input_list.inputs {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pattern we use a lot for this is input_list.unwrap_or_default()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this ?

input_list.inputs.unwrap_or_default().iter().for_each(f)...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added github suggestion

inputs.iter().for_each(|i| {
let input_arn = i.arn.to_owned().unwrap_or_default();
let input_name = i.name.to_owned().unwrap_or_default();

println!("Input Name : {}, Input ARN : {}", input_name, input_arn);
})
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if let Some(inputs) = input_list.inputs {
inputs.iter().for_each(|i| {
let input_arn = i.arn.to_owned().unwrap_or_default();
let input_name = i.name.to_owned().unwrap_or_default();
println!("Input Name : {}, Input ARN : {}", input_name, input_arn);
})
}
for input in input_list.inputs.unwrap_or_default() {
let input_arn = input.arn.as_deref().unwrap_or_default();
let input_name = input.name.as_deref().unwrap_or_default();
println!("Input Name : {}, Input ARN : {}", input_name, input_arn);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same pattern can be used in the other example

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as_deref() goes from Option<T> to Option<&T> when allows you do unwrap without taking ownership

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, let me make the changes.


Ok(())
}
15 changes: 15 additions & 0 deletions aws/sdk/examples/mediapackage-helloworld/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "mediapackage-helloworld"
version = "0.1.0"
authors = ["Alistair McLean <mclean@amazon.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
mediapackage = { package = "aws-sdk-mediapackage", path = "../../build/aws-sdk/mediapackage" }
### To use native TLS:
# mediapackage = { package = "aws-sdk-mediapackage", path = "../../build/aws-sdk/mediapackage", default-features = false, features = ["native-tls"] }
tokio = { version = "1", features = ["full"] }
# used only to enable basic logging:
env_logger = "0.8.2"
25 changes: 25 additions & 0 deletions aws/sdk/examples/mediapackage-helloworld/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

#[tokio::main]
async fn main() -> Result<(), mediapackage::Error> {
let client = mediapackage::Client::from_env();
let list_channels = client.list_channels().send().await?;

// List out all the mediapackage channels and display their ARN and description.
if let Some(channels) = list_channels.channels {
channels.iter().for_each(|c| {
let description = c.description.to_owned().unwrap_or_default();
let arn = c.arn.to_owned().unwrap_or_default();

println!(
"Channel Description : {}, Channel ARN : {}",
description, arn
);
});
}

Ok(())
}
15 changes: 15 additions & 0 deletions aws/sdk/examples/mediapackage-listendpoints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "mediapackage-listendpoints"
version = "0.1.0"
authors = ["Alistair McLean <mclean@amazon.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
mediapackage = { package = "aws-sdk-mediapackage", path = "../../build/aws-sdk/mediapackage" }
### To use native TLS:
# mediapackage = { package = "aws-sdk-mediapackage", path = "../../build/aws-sdk/mediapackage", default-features = false, features = ["native-tls"] }
tokio = { version = "1", features = ["full"] }
# used only to enable basic logging:
env_logger = "0.8.2"
23 changes: 23 additions & 0 deletions aws/sdk/examples/mediapackage-listendpoints/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

#[tokio::main]
async fn main() -> Result<(), mediapackage::Error> {
let client = mediapackage::Client::from_env();
let or_endpoints = client.list_origin_endpoints().send().await?;

if let Some(endpoints) = or_endpoints.origin_endpoints {
endpoints.iter().for_each(|e| {
let endpoint_url = e.url.to_owned().unwrap_or_default();
let endpoint_description = e.description.to_owned().unwrap_or_default();
println!(
"Endpoint Description: {}, Endpoint URL : {}",
endpoint_description, endpoint_url
);
})
}

Ok(())
}
Loading