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

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
Contributor

Choose a reason for hiding this comment

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

added github suggestion

@rcoh
Copy link
Contributor

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!

Comment on lines 6 to 13
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

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
Contributor

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
Contributor

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.

@rcoh rcoh merged commit fdc58ee into smithy-lang:main Jun 2, 2021
@rcoh
Copy link
Contributor

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
Development

Successfully merging this pull request may close these issues.

None yet

2 participants