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

New Services MediaLive and MediaPackage #449

merged 7 commits into from Jun 2, 2021

Conversation

@alistaim
Copy link
Contributor

@alistaim alistaim commented Jun 2, 2021

Description of changes:
Adding medialive and mediapackage models with minimal code examples for each.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

let client = medialive::Client::from_env();
let input_list = client.list_inputs().send().await?;

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

@rcoh rcoh Jun 2, 2021

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

Copy link
Contributor Author

@alistaim alistaim Jun 2, 2021

Like this ?

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

Copy link
Contributor

@rcoh rcoh Jun 2, 2021

added github suggestion

@rcoh
Copy link
Contributor

@rcoh rcoh commented Jun 2, 2021

Looks good—we're trying to migrate to one-crate-per-service with multiple binaries to make it a little more manageable when we have 260 services. Let me know if you need any guidance on making that refactoring. Otherwise LGTM!

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);
})
}
Copy link
Contributor

@rcoh rcoh Jun 2, 2021

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
Contributor

@rcoh rcoh Jun 2, 2021

same pattern can be used in the other example

Copy link
Contributor

@rcoh rcoh Jun 2, 2021

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

Copy link
Contributor Author

@alistaim alistaim Jun 2, 2021

Awesome, let me make the changes.

rcoh
rcoh approved these changes Jun 2, 2021
@rcoh rcoh merged commit fdc58ee into awslabs:main Jun 2, 2021
9 checks passed
@rcoh
Copy link
Contributor

@rcoh rcoh commented Jun 2, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants