Skip to content

Commit

Permalink
Handle nullability change for smithy-lang/smithy-rs#2995
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSouther committed Sep 28, 2023
1 parent 3334b85 commit 6d2153a
Show file tree
Hide file tree
Showing 81 changed files with 207 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async fn post_workitem_returns_200() {
.expect("failed to query rds");

assert_eq!(
result.records().unwrap().len(),
result.records().len(),
1,
"should have inserted one record"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct Opt {
async fn show_apis(client: &Client) -> Result<(), Error> {
let resp = client.get_rest_apis().send().await?;

for api in resp.items().unwrap_or_default() {
for api in resp.items() {
println!("ID: {}", api.id().unwrap_or_default());
println!("Name: {}", api.name().unwrap_or_default());
println!("Description: {}", api.description().unwrap_or_default());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ async fn show_policies(client: &Client) -> Result<(), Error> {
.service_namespace(ServiceNamespace::Ec2)
.send()
.await?;
if let Some(policies) = response.scaling_policies() {
println!("Auto Scaling Policies:");
for policy in policies {
println!("{:?}\n", policy);
}
println!("Auto Scaling Policies:");
for policy in response.scaling_policies() {
println!("{:?}\n", policy);
}
println!("Next token: {:?}", response.next_token());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ struct Opt {
async fn list_plans(client: &Client) -> Result<(), Error> {
let response = client.describe_scaling_plans().send().await?;

if let Some(plans) = response.scaling_plans() {
println!("Auto Scaling Plans:");
for plan in plans {
println!("{:?}\n", plan);
}
println!("Auto Scaling Plans:");
for plan in response.scaling_plans() {
println!("{:?}\n", plan);
}

Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Opt {
async fn show_envs(client: &Client) -> Result<(), Error> {
let rsp = client.describe_compute_environments().send().await?;

let compute_envs = rsp.compute_environments().unwrap_or_default();
let compute_envs = rsp.compute_environments();
println!("Found {} compute environments:", compute_envs.len());
for env in compute_envs {
let arn = env.compute_environment_arn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ async fn describe_stack(client: &Client, name: &str) -> Result<(), Error> {

// Otherwise we get an array of stacks that match the stack_name.
// The array should only have one item, so just access it via first().
let status = resp
.stacks()
.unwrap_or_default()
.first()
.unwrap()
.stack_status();
let status = resp.stacks().first().unwrap().stack_status();

println!("Stack status: {}", status.as_str());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Opt {
async fn list_stacks(client: &Client) -> Result<(), Error> {
let stacks = client.list_stacks().send().await?;

for stack in stacks.stack_summaries().unwrap_or_default() {
for stack in stacks.stack_summaries() {
println!("{}", stack.stack_name());
println!(" Status: {:?}", stack.stack_status());
println!();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async fn show_metrics(
client: &aws_sdk_cloudwatch::Client,
) -> Result<(), aws_sdk_cloudwatch::Error> {
let rsp = client.list_metrics().send().await?;
let metrics = rsp.metrics().unwrap_or_default();
let metrics = rsp.metrics();

let num_metrics = metrics.len();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn show_log_events(
.log_stream_name(stream)
.send()
.await?;
let events = log_events.events().unwrap_or_default();
let events = log_events.events();
println!("Found {} events:", events.len());
for event in events {
println!("message: {}", event.message().unwrap_or_default());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async fn show_log_groups(
client: &aws_sdk_cloudwatchlogs::Client,
) -> Result<(), aws_sdk_cloudwatchlogs::Error> {
let resp = client.describe_log_groups().send().await?;
let groups = resp.log_groups().unwrap_or_default();
let groups = resp.log_groups();
let num_groups = groups.len();
for group in groups {
println!(" {}", group.log_group_name().unwrap_or_default());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async fn show_log_streams(
.log_group_name(name)
.send()
.await?;
let streams = resp.log_streams().unwrap_or_default();
let streams = resp.log_streams();
println!("Found {} streams:", streams.len());
for stream in streams {
println!(" {}", stream.log_stream_name().unwrap_or_default());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ async fn describe_pool(client: &Client, id: &str) -> Result<(), Error> {
let allow_unauth_ids = response.allow_unauthenticated_identities();
println!(" Allow classic flow {}", allow_classic);
println!(" Allow unauthenticated identities: {}", allow_unauth_ids);
if let Some(providers) = response.cognito_identity_providers() {
println!(" Identity Providers:");
for provider in providers {
let client_id = provider.client_id().unwrap_or_default();
let name = provider.provider_name().unwrap_or_default();
let server_side_check = provider.server_side_token_check().unwrap_or_default();

println!(" Client ID: {}", client_id);
println!(" Name: {}", name);
println!(" Service-side token check: {}", server_side_check);
println!();
}
let providers = response.cognito_identity_providers();
println!(" Identity Providers:");
for provider in providers {
let client_id = provider.client_id().unwrap_or_default();
let name = provider.provider_name().unwrap_or_default();
let server_side_check = provider.server_side_token_check().unwrap_or_default();

println!(" Client ID: {}", client_id);
println!(" Name: {}", name);
println!(" Service-side token check: {}", server_side_check);
println!();
}

let developer_provider = response.developer_provider_name().unwrap_or_default();
Expand All @@ -59,26 +58,22 @@ async fn describe_pool(client: &Client, id: &str) -> Result<(), Error> {
println!(" Identity pool ID: {}", id);
println!(" Identity pool name: {}", name);

if let Some(tags) = response.identity_pool_tags() {
println!(" Tags:");
for (key, value) in tags {
println!(" key: {}", key);
println!(" value: {}", value);
}
println!(" Tags:");
for (key, value) in response.identity_pool_tags().unwrap() {
println!(" key: {}", key);
println!(" value: {}", value);
}

if let Some(open_id_arns) = response.open_id_connect_provider_ar_ns() {
println!(" Open ID provider ARNs:");
for arn in open_id_arns {
println!(" {}", arn);
}
let open_id_arns = response.open_id_connect_provider_ar_ns();
println!(" Open ID provider ARNs:");
for arn in open_id_arns {
println!(" {}", arn);
}

if let Some(saml_arns) = response.saml_provider_ar_ns() {
println!(" SAML provider ARNs:");
for arn in saml_arns {
println!(" {}", arn);
}
let saml_arns = response.saml_provider_ar_ns();
println!(" SAML provider ARNs:");
for arn in saml_arns {
println!(" {}", arn);
}

// SupportedLoginProviders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ async fn list_pools(client: &Client) -> Result<(), Error> {
let response = client.list_identity_pools().max_results(10).send().await?;

// Print IDs and names of pools.
if let Some(pools) = response.identity_pools() {
println!("Identity pools:");
for pool in pools {
let id = pool.identity_pool_id().unwrap_or_default();
let name = pool.identity_pool_name().unwrap_or_default();
println!(" Identity pool ID: {}", id);
println!(" Identity pool name: {}", name);
println!();
}
let pools = response.identity_pools();
println!("Identity pools:");
for pool in pools {
let id = pool.identity_pool_id().unwrap_or_default();
let name = pool.identity_pool_name().unwrap_or_default();
println!(" Identity pool ID: {}", id);
println!(" Identity pool name: {}", name);
println!();
}

println!("Next token: {:?}", response.next_token());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,22 @@ async fn list_identities(client: &Client, pool_id: &str) -> Result<(), Error> {
.send()
.await?;

if let Some(ids) = response.identities() {
println!("Identitities:");
for id in ids {
let creation_timestamp = (*id.creation_date().unwrap()).to_chrono_utc()?;
let idid = id.identity_id().unwrap_or_default();
let mod_timestamp = (*id.last_modified_date().unwrap()).to_chrono_utc()?;
println!(" Creation date: {}", creation_timestamp);
println!(" ID: {}", idid);
println!(" Last modified date: {}", mod_timestamp);

println!(" Logins:");
for login in id.logins().unwrap_or_default() {
println!(" {}", login);
}

println!();
let ids = response.identities();
println!("Identitities:");
for id in ids {
let creation_timestamp = (*id.creation_date().unwrap()).to_chrono_utc()?;
let idid = id.identity_id().unwrap_or_default();
let mod_timestamp = (*id.last_modified_date().unwrap()).to_chrono_utc()?;
println!(" Creation date: {}", creation_timestamp);
println!(" ID: {}", idid);
println!(" Last modified date: {}", mod_timestamp);

println!(" Logins:");
for login in id.logins() {
println!(" {}", login);
}

println!();
}

println!("Next token: {:?}", response.next_token());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,22 @@ struct Opt {
// snippet-start:[cognitoidentityprovider.rust.list-user-pools]
async fn show_pools(client: &Client) -> Result<(), Error> {
let response = client.list_user_pools().max_results(10).send().await?;
if let Some(pools) = response.user_pools() {
println!("User pools:");
for pool in pools {
println!(" ID: {}", pool.id().unwrap_or_default());
println!(" Name: {}", pool.name().unwrap_or_default());
println!(" Status: {:?}", pool.status());
println!(" Lambda Config: {:?}", pool.lambda_config().unwrap());
println!(
" Last modified: {}",
pool.last_modified_date().unwrap().to_chrono_utc()?
);
println!(
" Creation date: {:?}",
pool.creation_date().unwrap().to_chrono_utc()
);
println!();
}
let pools = response.user_pools();
println!("User pools:");
for pool in pools {
println!(" ID: {}", pool.id().unwrap_or_default());
println!(" Name: {}", pool.name().unwrap_or_default());
println!(" Status: {:?}", pool.status());
println!(" Lambda Config: {:?}", pool.lambda_config().unwrap());
println!(
" Last modified: {}",
pool.last_modified_date().unwrap().to_chrono_utc()?
);
println!(
" Creation date: {:?}",
pool.creation_date().unwrap().to_chrono_utc()
);
println!();
}
println!("Next token: {}", response.next_token().unwrap_or_default());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,27 @@ async fn show_pools(client: &Client) -> Result<(), Error> {
.send()
.await?;

if let Some(pools) = response.identity_pool_usages() {
println!("Identity pools:");

for pool in pools {
println!(
" Identity pool ID: {}",
pool.identity_pool_id().unwrap_or_default()
);
println!(
" Data storage: {}",
pool.data_storage().unwrap_or_default()
);
println!(
" Sync sessions count: {}",
pool.sync_sessions_count().unwrap_or_default()
);
println!(
" Last modified: {}",
pool.last_modified_date().unwrap().to_chrono_utc()?
);
println!();
}
let pools = response.identity_pool_usages();
println!("Identity pools:");

for pool in pools {
println!(
" Identity pool ID: {}",
pool.identity_pool_id().unwrap_or_default()
);
println!(
" Data storage: {}",
pool.data_storage().unwrap_or_default()
);
println!(
" Sync sessions count: {}",
pool.sync_sessions_count().unwrap_or_default()
);
println!(
" Last modified: {}",
pool.last_modified_date().unwrap().to_chrono_utc()?
);
println!();
}

println!("Next token: {}", response.next_token().unwrap_or_default());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn get_history(client: &Client, id: &str, res: ResourceType) -> Result<(),

println!("configuration history for {}:", id);

for item in rsp.configuration_items().unwrap_or_default() {
for item in rsp.configuration_items() {
println!("item: {:?}", item);
}

Expand Down
4 changes: 2 additions & 2 deletions rust_dev_preview/examples/config/src/bin/enable-config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async fn enable_config(
// If we already have a configuration recorder in the Region, we cannot create another.
let resp = client.describe_configuration_recorders().send().await?;

let recorders = resp.configuration_recorders().unwrap_or_default();
let recorders = resp.configuration_recorders();

if !recorders.is_empty() {
println!("You already have a configuration recorder in this region");
Expand All @@ -83,7 +83,7 @@ async fn enable_config(
// If we already have a delivery channel in the Region, we cannot create another.
let resp = client.describe_delivery_channels().send().await?;

let channels = resp.delivery_channels().unwrap_or_default();
let channels = resp.delivery_channels();

let num_channels = channels.len();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Opt {
async fn show_recorders(client: &Client) -> Result<(), Error> {
let resp = client.describe_configuration_recorders().send().await?;

let recorders = resp.configuration_recorders().unwrap_or_default();
let recorders = resp.configuration_recorders();

if recorders.is_empty() {
println!("You have no configuration recorders")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Opt {
async fn show_channels(client: &Client) -> Result<(), Error> {
let resp = client.describe_delivery_channels().send().await?;

let channels = resp.delivery_channels().unwrap_or_default();
let channels = resp.delivery_channels();

let num_channels = channels.len();

Expand Down
2 changes: 1 addition & 1 deletion rust_dev_preview/examples/config/src/bin/list-resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async fn show_resources(verbose: bool, client: &Client) -> Result<(), Error> {
.send()
.await?;

let resources = resp.resource_identifiers().unwrap_or_default();
let resources = resp.resource_identifiers();

if !resources.is_empty() || verbose {
println!();
Expand Down
Loading

0 comments on commit 6d2153a

Please sign in to comment.