Skip to content

Commit 33dc607

Browse files
authored
fix iothub device update by bumping api version to 2022-10-01 (#1636)
* chore: updated iothub device update api version to 2022-10-01 * fixed finding * qa * fix tests
1 parent 7ac895a commit 33dc607

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

sdk/iot_deviceupdate/src/client.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use const_format::formatcp;
77
use serde::de::DeserializeOwned;
88
use std::sync::Arc;
99

10-
pub(crate) const API_VERSION: &str = "2021-06-01-preview";
10+
pub(crate) const API_VERSION: &str = "2022-10-01";
1111
pub(crate) const API_VERSION_PARAM: &str = formatcp!("api-version={}", API_VERSION);
1212

1313
/// Client for Device Update operations - import, list and delete updates
@@ -45,6 +45,7 @@ impl DeviceUpdateClient {
4545
.with_context(ErrorKind::DataConversion, || {
4646
format!("failed to parse update url: {device_update_url}")
4747
})?;
48+
4849
let endpoint = extract_endpoint(&device_update_url)?;
4950

5051
let client = DeviceUpdateClient {
@@ -153,7 +154,8 @@ fn extract_endpoint(url: &Url) -> azure_core::Result<String> {
153154
})
154155
})?
155156
.1;
156-
Ok(format!("{}://{}", url.scheme(), endpoint))
157+
158+
Ok(format!("{}://{}{}", url.scheme(), endpoint, azure_core::auth::DEFAULT_SCOPE_SUFFIX))
157159
}
158160

159161
#[cfg(test)]
@@ -164,16 +166,16 @@ mod tests {
164166
fn can_extract_endpoint() -> azure_core::Result<()> {
165167
let url = "https://myadu.api.adu.microsoft.com";
166168
let suffix = extract_endpoint(&Url::parse(url)?)?;
167-
assert_eq!(suffix, "https://api.adu.microsoft.com");
169+
assert_eq!(suffix, "https://api.adu.microsoft.com/.default");
168170

169171
let suffix = extract_endpoint(&Url::parse("https://myadu.mycustom.api.adu.server.net")?)?;
170-
assert_eq!(suffix, "https://mycustom.api.adu.server.net");
172+
assert_eq!(suffix, "https://mycustom.api.adu.server.net/.default");
171173

172174
let suffix = extract_endpoint(&Url::parse("https://myadu.internal")?)?;
173-
assert_eq!(suffix, "https://internal");
175+
assert_eq!(suffix, "https://internal/.default");
174176

175177
let suffix = extract_endpoint(&Url::parse("some-scheme://myadu.api.adu.microsoft.com")?)?;
176-
assert_eq!(suffix, "some-scheme://api.adu.microsoft.com");
178+
assert_eq!(suffix, "some-scheme://api.adu.microsoft.com/.default");
177179
Ok(())
178180
}
179181

sdk/iot_deviceupdate/src/device_update.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,16 @@ pub struct UpdateList {
166166

167167
impl DeviceUpdateClient {
168168
/// Import new update version.
169-
/// `POST https://{endpoint}/deviceupdate/{instanceId}/updates?action=import&api-version=2021-06-01-preview`
169+
/// `POST https://{endpoint}/deviceUpdate/{instanceId}/updates:import?api-version=2022-10-01`
170170
pub async fn import_update(
171171
&self,
172172
instance_id: &str,
173173
import_json: String,
174174
) -> azure_core::Result<UpdateOperation> {
175175
let mut uri = self.device_update_url.clone();
176-
let path = format!("deviceupdate/{instance_id}/updates");
176+
let path = format!("deviceupdate/{instance_id}/updates:import");
177177
uri.set_path(&path);
178178
uri.set_query(Some(API_VERSION_PARAM));
179-
uri.query_pairs_mut().append_pair("action", "import");
180179

181180
debug!("Import request: {}", &uri);
182181
let resp_body = self.post(uri.to_string(), Some(import_json)).await?;
@@ -215,7 +214,7 @@ impl DeviceUpdateClient {
215214
}
216215

217216
/// Delete a specific update version.
218-
/// `DELETE https://{endpoint}/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}?api-version=2021-06-01-preview`
217+
/// `DELETE https://{endpoint}/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}?api-version=2022-10-01`
219218
pub async fn delete_update(
220219
&self,
221220
instance_id: &str,
@@ -232,7 +231,7 @@ impl DeviceUpdateClient {
232231
}
233232

234233
/// Get a specific update file from the version.
235-
/// `GET https://{endpoint}/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}?api-version=2021-06-01-previe`
234+
/// `GET https://{endpoint}/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}?api-version=2022-10-01`
236235
pub async fn get_file(
237236
&self,
238237
instance_id: &str,
@@ -250,7 +249,7 @@ impl DeviceUpdateClient {
250249
}
251250

252251
/// Retrieve operation status.
253-
/// `GET https://{endpoint}/deviceupdate/{instanceId}/updates/operations/{operationId}?api-version=2021-06-01-preview`
252+
/// `GET https://{endpoint}/deviceUpdate/{instanceId}/updates/operations/{operationId}?api-version=2022-10-01`
254253
pub async fn get_operation(
255254
&self,
256255
instance_id: &str,
@@ -265,7 +264,7 @@ impl DeviceUpdateClient {
265264
}
266265

267266
/// Get a specific update version.
268-
/// `GET https://{endpoint}/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}?api-version=2021-06-01-preview`
267+
/// `GET https://{endpoint}/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}?api-version=2022-10-01`
269268
pub async fn get_update(
270269
&self,
271270
instance_id: &str,
@@ -282,7 +281,7 @@ impl DeviceUpdateClient {
282281
}
283282

284283
/// Get a list of all update file identifiers for the specified version.
285-
/// `GET https://{endpoint}/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files?api-version=2021-06-01-preview`
284+
/// `GET https://{endpoint}/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files?api-version=2022-10-01`
286285
pub async fn list_files(
287286
&self,
288287
instance_id: &str,
@@ -317,7 +316,7 @@ impl DeviceUpdateClient {
317316
}
318317

319318
/// Get a list of all update names that match the specified provider.
320-
/// `GET https://{endpoint}/deviceupdate/{instanceId}/updates/providers/{provider}/names?api-version=2021-06-01-preview`
319+
/// `GET https://{endpoint}/deviceUpdate/{instanceId}/updates/providers/{provider}/names?api-version=2022-10-01`
321320
pub async fn list_names(
322321
&self,
323322
instance_id: &str,
@@ -351,7 +350,7 @@ impl DeviceUpdateClient {
351350

352351
/// Get a list of all import update operations.
353352
/// Completed operations are kept for 7 days before auto-deleted. Delete operations are not returned by this API version.
354-
/// `GET https://{endpoint}/deviceupdate/{instanceId}/updates/operations?$filter={$filter}&$top={$top}&api-version=2021-06-01-preview`
353+
/// `GET https://{endpoint}/deviceUpdate/{instanceId}/updates/operations?filter={filter}&top={top}&api-version=2022-10-01`
355354
pub async fn list_operations(
356355
&self,
357356
instance_id: &str,
@@ -392,7 +391,7 @@ impl DeviceUpdateClient {
392391
}
393392

394393
/// Get a list of all update providers that have been imported to Device Update for `IoT` Hub.
395-
/// `GET https://{endpoint}/deviceupdate/{instanceId}/updates/providers?api-version=2021-06-01-preview`
394+
/// `GET https://{endpoint}/deviceUpdate/{instanceId}/updates/providers?api-version=2022-10-01`
396395
pub async fn list_providers(&self, instance_id: &str) -> azure_core::Result<Vec<String>> {
397396
let mut uri = self.device_update_url.clone();
398397
let path = format!("deviceupdate/{instance_id}/updates/providers");
@@ -421,7 +420,7 @@ impl DeviceUpdateClient {
421420
}
422421

423422
/// Get a list of all updates that have been imported to Device Update for `IoT` Hub.
424-
/// `GET https://{endpoint}/deviceupdate/{instanceId}/updates?api-version=2021-06-01-preview&$search={$search}&$filter={$filter}`
423+
/// `GET https://{endpoint}/deviceUpdate/{instanceId}/updates?api-version=2022-10-01&search={search}&filter={filter}`
425424
pub async fn list_updates(
426425
&self,
427426
instance_id: &str,
@@ -463,7 +462,7 @@ impl DeviceUpdateClient {
463462
}
464463

465464
/// Get a list of all update versions that match the specified provider and name.
466-
/// `GET https://{endpoint}/deviceupdate/{instanceId}/updates/providers/{provider}/names/{name}/versions?api-version=2021-06-01-preview&$filter={$filter}`
465+
/// `GET https://{endpoint}/deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions?api-version=2022-10-01&filter={filter}`
467466
pub async fn list_versions(
468467
&self,
469468
instance_id: &str,
@@ -516,7 +515,7 @@ mod tests {
516515
async fn can_import_update() -> azure_core::Result<()> {
517516
let mut server = Server::new_async().await;
518517
let _m = server
519-
.mock("POST", "/deviceupdate/test-instance/updates")
518+
.mock("POST", "/deviceupdate/test-instance/updates:import")
520519
.match_query(Matcher::UrlEncoded(
521520
"api-version".into(),
522521
API_VERSION.into(),
@@ -533,7 +532,7 @@ mod tests {
533532
"lastActionDateTime":"1999-09-10T03:05:07.3845533+01:00",
534533
"etag": "\"some_tag\"",
535534
"operationId": "some_op_id",
536-
"resourceLocation": "/deviceupdate/instance/updates/providers/xxx/names/yyy/versions/x.y.z?api-version=2021-06-01-preview",
535+
"resourceLocation": "/deviceupdate/instance/updates/providers/xxx/names/yyy/versions/x.y.z?api-version=2022-10-01",
537536
"status": "Succeeded",
538537
"traceId": "zzzzzzzzzzzzzzzz",
539538
"updateId": {

0 commit comments

Comments
 (0)