hello
I was working on a client to automate some function is multiple vm
I was trying to find private ip address (that is still not working)
so I decided to use list api. this did not compile. so I made a fix for list API not working
here is a test client
/*
prints information about network addresses used for each Azure VM in resource group
$ cargo run --release --example list_ip_configuration <resource_group>
$
*/
use azure_identity::AzureCliCredential;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resource_group_name = std::env::args().nth(1).expect("please specify resource group name");
let credential = Arc::new(AzureCliCredential::new());
let subscription_id = AzureCliCredential::get_subscription().await?;
let network_client = azure_mgmt_network::Client::builder(credential).build()?;
let nics = network_client.network_interfaces_client().list(resource_group_name, subscription_id).await.unwrap().value;
for entry in nics {
if let Some(props) = entry.properties {
let ip_configs = props.ip_configurations;
for ip_config in ip_configs {
if let Some(ip_config_props) = ip_config.properties {
if let Some(private_ip_address) = ip_config_props.private_ip_address {
println!("{:?}", private_ip_address);
}
}
}
}
}
Ok(())
}
here is the compile error
Compiling azure_mgmt_network v0.20.0 (/home/rohitsi/work/projects/azure-sdk-for-rust/services/mgmt/network)
error[E0277]: `azure_mgmt_network::network_interfaces::list::RequestBuilder` is not a future
--> mgmt/network/examples/list_ip_configuration.rs:19:102
|
19 | ...scription_id).await.unwrap().value;
| -^^^^^
| ||
| |`azure_mgmt_network::network_interfaces::list::RequestBuilder` is not a future
| help: remove the `.await`
|
= help: the trait `Future` is not implemented for `azure_mgmt_network::network_interfaces::list::RequestBuilder`
= note: azure_mgmt_network::network_interfaces::list::RequestBuilder must be a future or must implement `IntoFuture` to be awaited
= note: required for `azure_mgmt_network::network_interfaces::list::RequestBuilder` to implement `IntoFuture`
For more information about this error, try `rustc --explain E0277`.
error: could not compile `azure_mgmt_network` (example "list_ip_configuration") due to previous error
FAIL: 101
here is the patch on how I seem to fix it. ( I am new to rust so I did not feel comforable to open a PR)
Index: services/mgmt/network/src/package_2023_09/mod.rs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/services/mgmt/network/src/package_2023_09/mod.rs b/services/mgmt/network/src/package_2023_09/mod.rs
--- a/services/mgmt/network/src/package_2023_09/mod.rs (revision 8c4caa251c3903d5eae848b41bb1d02a4d65231c)
+++ b/services/mgmt/network/src/package_2023_09/mod.rs (date 1719241474768)
@@ -4383,6 +4383,24 @@
pub(crate) subscription_id: String,
}
impl RequestBuilder {
+ #[doc = "Returns a future that sends the request and returns a [`Response`] object that provides low-level access to full response details."]
+ #[doc = ""]
+ #[doc = "You should typically use `.await` (which implicitly calls `IntoFuture::into_future()`) to finalize and send requests rather than `send()`."]
+ #[doc = "However, this function can provide more flexibility when required."]
+ pub fn send(self) -> BoxFuture<'static, azure_core::Result<Response>> {
+ Box::pin({
+ let this = self.clone();
+ async move {
+ let url = this.url()?;
+ let mut req = azure_core::Request::new(url, azure_core::Method::Get);
+ let bearer_token = this.client.bearer_token().await?;
+ req.insert_header(azure_core::headers::AUTHORIZATION, format!("Bearer {}", bearer_token.secret()));
+ let req_body = azure_core::EMPTY_BODY;
+ req.set_body(req_body);
+ Ok(Response(this.client.send(&mut req).await?))
+ }
+ })
+ }
pub fn into_stream(self) -> azure_core::Pageable<models::NetworkInterfaceListResult, azure_core::error::Error> {
let make_request = move |continuation: Option<String>| {
let this = self.clone();
@@ -4442,6 +4460,19 @@
Ok(url)
}
}
+ impl std::future::IntoFuture for RequestBuilder {
+ type Output = azure_core::Result<models::NetworkInterfaceListResult>;
+ type IntoFuture = BoxFuture<'static, azure_core::Result<models::NetworkInterfaceListResult>>;
+ #[doc = "Returns a future that sends the request and returns the parsed response body."]
+ #[doc = ""]
+ #[doc = "You should not normally call this method directly, simply invoke `.await` which implicitly calls `IntoFuture::into_future`."]
+ #[doc = ""]
+ #[doc = "See [IntoFuture documentation](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) for more details."]
+ fn into_future(self) -> Self::IntoFuture {
+ Box::pin(async move { self.send().await?.into_body().await })
+ }
+ }
+
}
pub mod get_effective_route_table {
use super::models;
hello I was working on a client to automate some function is multiple vm
I was trying to find private ip address (that is still not working)
so I decided to use list api. this did not compile. so I made a fix for list API not working
here is a test client
here is the compile error
here is the patch on how I seem to fix it. ( I am new to rust so I did not feel comforable to open a PR)
please merge if appropriate
Thank you for your time