Skip to content

into_future for services #527

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

Merged
merged 44 commits into from
Nov 29, 2021
Merged

Conversation

cataggar
Copy link
Member

@cataggar cataggar commented Nov 19, 2021

This is executing on the plan in #520 to use into_future for generated services. It is a major update. This PR:

  • replaces OperationConfig & OperationConfigBuilder with Client and ClientBuilder. Fixes generate Clients for services #50.
  • makes subclients available based on operation groups.
  • each operation has a Builder that implements into_future.

into_future is implemented as originally specified in #510 with:

pub fn into_future(self) -> futures::future::BoxFuture<'static, std::result::Result<Response, Error>> {

I think the API shape remains the same, but it does not follow what was later specified. It specifies:

pub fn into_future(&self) -> Pin<Box<dyn Future<Output = crate::Result<OperationResponse> + Send + 'static>>
  • Builder::context not yet supported
  • Builder::insert not yet supported
  • IntoFuture is not yet implemented

I'd prefer to make those adjustments and additions in another PR.

@cataggar cataggar changed the title ìnto_future` for services into_future for services Nov 19, 2021

let accounts = batch_account::list(config, subscription_id).await?;
let accounts = client.batch_account().list(subscription_id).into_future().await?;
Copy link
Member Author

Choose a reason for hiding this comment

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

👍

let pools = pool::list_by_batch_account(config, &resource_group_name, &account_name, None, None, None, subscription_id).await?;
let pools = client
.pool()
.list_by_batch_account(resource_group_name, account_name, subscription_id)
Copy link
Member Author

Choose a reason for hiding this comment

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

👍


let vms = virtual_machines::list_all(config, subscription_id, None).await?;
let vms = client.virtual_machines().list_all(subscription_id).into_future().await?;
Copy link
Member Author

Choose a reason for hiding this comment

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

👍


let accounts = storage_accounts::list(config, subscription_id).await?;
let accounts = client.storage_accounts().list(subscription_id).into_future().await?;
Copy link
Member Author

Choose a reason for hiding this comment

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

👍


let clouds = private_clouds::list_in_subscription(config, subscription_id).await?;
let clouds = client.private_clouds().list_in_subscription(subscription_id).into_future().await?;
Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@@ -74,7 +73,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
};

println!("creating task");
task::add(&config, &job_id, &task, None, None, None, None).await?;
client.task().add(job_id, task).into_future().await?;
Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@@ -50,7 +49,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
};

println!("creating job");
job::add(&config, &job_params, None, None, None, None).await?;
client.job().add(job_params).into_future().await?;
Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@cataggar cataggar marked this pull request as ready for review November 28, 2021 00:54
@cataggar cataggar mentioned this pull request Nov 28, 2021
2 tasks
This was referenced Nov 28, 2021
@bmc-msft
Copy link
Contributor

This made my project that uses an SVC crate significantly less cumbersome.

Specifically, I was using svc/batch. My code went from this:

let result = task::get(&config, &job_id, &task_id, None, None, None, None, None, None, None, None, None, None).await;

To this:

let result = batch_client.task().get(&job_id, &task_id).into_future().await;

@cataggar cataggar merged commit abee6e5 into Azure:main Nov 29, 2021
@cataggar cataggar deleted the services_into_future2 branch May 6, 2022 23:20
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.

generate Clients for services
3 participants