-
Notifications
You must be signed in to change notification settings - Fork 314
Add Device update functionality #694
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
Conversation
let s_filter= match env::var("DEVICE_UPDATE_FILTER") { | ||
Err(_e) => { "".to_owned() }, | ||
Ok(s) => { s } | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let s_filter= match env::var("DEVICE_UPDATE_FILTER") { | |
Err(_e) => { "".to_owned() }, | |
Ok(s) => { s } | |
}; | |
let s_filter = env::var("DEVICE_UPDATE_FILTER").unwrap_or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thank you
Perhaps this would be a good candidate to wrap the service-generated code in a rust-idiomatic layer. For reference: generated crate and docs |
I tried to do that in the beginning so as not to copy all the struct and enum definitions, but I ran into problems with integrating the svc crate and the sdk crate together due to Rusts checks on how crates can reference each other and could not get it to even compile. Is there an example on how to do this I could look at? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing! I think this is a good start though we'll want to start moving towards things like using the pipeline architecture like we do in azure_data_cosmos
. I'll merge this for now, and we can make improvements in follow-up PRs.
serde = { version = "1.0", features = ["derive"] } | ||
getset = "0.1" | ||
azure_core = { path = "../core", version = "0.2" } | ||
tokio = { version = "1.0", features = ["full"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't need to depend on tokio
.
@@ -0,0 +1,36 @@ | |||
use azure_device_update::DeviceUpdateClient; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a lot of these examples should be tests instead and combined together.
/// let client = DeviceUpdateClient::new("contoso.api.adu.microsoft.com", &creds).unwrap(); | ||
/// ``` | ||
#[derive(Debug)] | ||
pub struct DeviceUpdateClient<'a, T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're generally avoiding tying clients to some specific lifetime. We should just make it easily cloneable.
let resp = reqwest::Client::new() | ||
.put(&uri) | ||
.bearer_auth(self.token.as_ref().unwrap().token.secret()) | ||
.header("Content-Type", "application/json") | ||
.body(body) | ||
.send() | ||
.await | ||
.unwrap(); | ||
let body = resp.text().await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to use the pipeline architecture we're using in azure_data_ cosmos
.
This PR implements the Azure Device Update API. The code is based on the security_keyvault crate.
Feedback welcome even if the PR is not merged.