Skip to content
Draft
5 changes: 5 additions & 0 deletions azext_iot/deviceupdate/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ def load_deviceupdate_help():
--update-name {update_name} --update-provider {update_provider} --update-version {update_version}
--failed-count 10 --failed-percentage 5 --rollback-update-name {rollback_update_name} --rollback-update-provider {rollback_update_provider}
--rollback-update-version {rollback_update_version}

- name: Create a device group deployment using HTTP (not recommended; compatibility only) for update payload downloads.
text: >
az iot du device deployment create -n {account_name} -i {instance_name} --group-id {device_group_id} --deployment-id {deployment_id}
--update-name {update_name} --update-provider {update_provider} --update-version {update_version} --download-security http
"""

helps["iot du device deployment list"] = """
Expand Down
2 changes: 2 additions & 0 deletions azext_iot/deviceupdate/commands_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def create_deployment(
rollback_update_version: Optional[str] = None,
devices_failed_percentage: Optional[str] = None,
devices_failed_count: Optional[str] = None,
download_security: Optional[str] = None,
resource_group_name: Optional[str] = None,
):
if any(
Expand Down Expand Up @@ -105,6 +106,7 @@ def create_deployment(
group_id=device_group_id,
update=update_info,
rollback_policy=rollback_policy,
download_security=download_security,
)
try:
return data_manager.data_client.device_management.create_or_update_deployment(
Expand Down
3 changes: 1 addition & 2 deletions azext_iot/deviceupdate/commands_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def import_devices(
)

try:
# @digimaun - There is a mismatch between spec and implementation expectation.
return data_manager.data_client.device_management.begin_import_devices(import_type={"importType": import_type})
return data_manager.data_client.device_management.begin_import_devices(import_type=import_type)
except AzureError as e:
handle_service_exception(e)

Expand Down
9 changes: 9 additions & 0 deletions azext_iot/deviceupdate/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ class ADUValidHashAlgorithmType(Enum):
SHA256 = "sha256"


class ADUDownloadSecurityType(Enum):
Comment thread
ketkimnaik marked this conversation as resolved.
"""
ADU download security (protocol) type for update payload downloads.
"""

HTTPS = "https"
HTTP = "http"


class ADUContentHandlerType(Enum):
"""
ADU first-party content handler types.
Expand Down
8 changes: 8 additions & 0 deletions azext_iot/deviceupdate/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
ADUPublicNetworkAccessType,
ADUPrivateLinkServiceConnectionStatus,
ADUAccountSKUType,
ADUDownloadSecurityType,
ADUManageDeviceImportType,
ADUValidHashAlgorithmType,
)
Expand Down Expand Up @@ -426,6 +427,13 @@ def load_deviceupdate_arguments(self, _):
"Required when defining rollback policy.",
arg_group="Update Rollback Policy",
)
context.argument(
"download_security",
options_list=["--download-security"],
help="Protocol used for update payload downloads. Defaults to https (TLS). "
"Use http only when the target environment does not support TLS.",
arg_type=get_enum_type(ADUDownloadSecurityType),
)
Comment thread
ketkimnaik marked this conversation as resolved.

with self.argument_context("iot du device log") as context:
context.argument(
Expand Down
4 changes: 3 additions & 1 deletion azext_iot/sdk/deviceupdate/dataplane/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0)
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
22 changes: 12 additions & 10 deletions azext_iot/sdk/deviceupdate/dataplane/_configuration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0)
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand All @@ -24,39 +26,39 @@ class DeviceUpdateClientConfiguration(Configuration): # pylint: disable=too-man

:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param instance_id: The Device Update for IoT Hub account instance identifier. Required.
:type instance_id: str
:param endpoint: The Device Update for IoT Hub account endpoint (hostname only, no protocol).
Required.
:type endpoint: str
:param instance_id: The Device Update for IoT Hub account instance identifier. Required.
:type instance_id: str
:keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2026-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
self,
credential: "TokenCredential",
endpoint: str,
instance_id: str,
endpoint: str,
**kwargs: Any
) -> None:
super(DeviceUpdateClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop('api_version', "2022-10-01") # type: str
api_version = kwargs.pop('api_version', "2026-06-01") # type: str
Comment thread
ketkimnaik marked this conversation as resolved.

Comment thread
ketkimnaik marked this conversation as resolved.
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
if instance_id is None:
raise ValueError("Parameter 'instance_id' must not be None.")
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")

self.credential = credential
self.endpoint = endpoint
self.instance_id = instance_id
self.endpoint = endpoint
self.api_version = api_version
self.credential_scopes = kwargs.pop('credential_scopes', ['https://api.adu.microsoft.com/.default'])
kwargs.setdefault('sdk_moniker', 'deviceupdateclient/{}'.format(VERSION))
kwargs.setdefault('sdk_moniker', 'iot-deviceupdate/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(
Expand Down
26 changes: 14 additions & 12 deletions azext_iot/sdk/deviceupdate/dataplane/_device_update_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0)
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand All @@ -27,18 +29,18 @@ class DeviceUpdateClient: # pylint: disable=client-accepts-api-version-keyword
knows when and how to update devices, enabling customers to focus on their business goals and
let Device Update for IoT Hub handle the updates.

:ivar device_update: DeviceUpdateOperations operations
:vartype device_update: deviceupdateclient.operations.DeviceUpdateOperations
:ivar device_management: DeviceManagementOperations operations
:vartype device_management: deviceupdateclient.operations.DeviceManagementOperations
:vartype device_management: azure.iot.deviceupdate.operations.DeviceManagementOperations
:ivar device_update: DeviceUpdateOperations operations
:vartype device_update: azure.iot.deviceupdate.operations.DeviceUpdateOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param instance_id: The Device Update for IoT Hub account instance identifier. Required.
:type instance_id: str
:param endpoint: The Device Update for IoT Hub account endpoint (hostname only, no protocol).
Required.
:type endpoint: str
:param instance_id: The Device Update for IoT Hub account instance identifier. Required.
:type instance_id: str
:keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2026-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Expand All @@ -48,22 +50,22 @@ class DeviceUpdateClient: # pylint: disable=client-accepts-api-version-keyword
def __init__(
self,
credential: "TokenCredential",
endpoint: str,
instance_id: str,
endpoint: str,
**kwargs: Any
) -> None:
_endpoint = 'https://{endpoint}'
self._config = DeviceUpdateClientConfiguration(credential=credential, endpoint=endpoint, instance_id=instance_id, **kwargs)
self._config = DeviceUpdateClientConfiguration(credential=credential, instance_id=instance_id, endpoint=endpoint, **kwargs)
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.device_update = DeviceUpdateOperations(
self.device_management = DeviceManagementOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.device_management = DeviceManagementOperations(
self.device_update = DeviceUpdateOperations(
self._client, self._config, self._serialize, self._deserialize
)

Expand Down Expand Up @@ -92,7 +94,7 @@ def _send_request(

request_copy = deepcopy(request)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str'),
}

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
Expand Down
12 changes: 1 addition & 11 deletions azext_iot/sdk/deviceupdate/dataplane/_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,7 @@

from typing import Dict, Any, cast, TYPE_CHECKING

from azext_iot.constants import INTERNAL_AZURE_CORE_NAMESPACE

try:
# @digimaun
from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback
except ImportError:
import importlib
internal_azure_core = importlib.import_module(INTERNAL_AZURE_CORE_NAMESPACE)
DeserializationError = internal_azure_core.exceptions.DeserializationError
SerializationError = internal_azure_core.exceptions.SerializationError
raise_with_traceback = internal_azure_core.exceptions.raise_with_traceback
from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback

_BOM = codecs.BOM_UTF8.decode(encoding='utf-8')

Expand Down
4 changes: 3 additions & 1 deletion azext_iot/sdk/deviceupdate/dataplane/_vendor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0)
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
6 changes: 4 additions & 2 deletions azext_iot/sdk/deviceupdate/dataplane/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0)
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "0.0.1"
VERSION = "1.1.0"
6 changes: 5 additions & 1 deletion azext_iot/sdk/deviceupdate/dataplane/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0)
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down Expand Up @@ -74,6 +76,7 @@
from ._device_update_client_enums import DeviceClassSubgroupDeploymentState
from ._device_update_client_enums import DeviceDeploymentState
from ._device_update_client_enums import DeviceHealthState
from ._device_update_client_enums import DownloadSecurity
from ._device_update_client_enums import GroupType
from ._device_update_client_enums import HealthCheckResult
from ._device_update_client_enums import ImportType
Expand Down Expand Up @@ -152,6 +155,7 @@
'DeviceClassSubgroupDeploymentState',
'DeviceDeploymentState',
'DeviceHealthState',
'DownloadSecurity',
'GroupType',
'HealthCheckResult',
'ImportType',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.2, generator: @autorest/python@5.19.0)
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand All @@ -14,14 +16,14 @@ class DeploymentState(str, Enum, metaclass=CaseInsensitiveEnumMeta):

#: The deployment can be sent to devices targeted in the deployment.
ACTIVE = "Active"
#: The deployment can be sent to some devices targeted in the deployment but at least 1 subgroup
#: is in a failed state.
#: The deployment can be sent to some devices targeted in the deployment but at
#: least 1 subgroup is in a failed state.
ACTIVE_WITH_SUBGROUP_FAILURES = "ActiveWithSubgroupFailures"
#: The deployment will not be sent to any devices. Consult error for more details about what
#: failed.
#: The deployment will not be sent to any devices. Consult error for more details
#: about what failed.
FAILED = "Failed"
#: A newer deployment for this group has been created and no devices in the group will receive
#: this deployment.
#: A newer deployment for this group has been created and no devices in the group
#: will receive this deployment.
INACTIVE = "Inactive"
#: The deployment has been canceled and no devices will receive it.
CANCELED = "Canceled"
Expand All @@ -34,8 +36,8 @@ class DeviceClassSubgroupDeploymentState(str, Enum, metaclass=CaseInsensitiveEnu
ACTIVE = "Active"
#: The subgroup deployment failed and will not be sent to any devices.
FAILED = "Failed"
#: A newer deployment for this subgroup has been created and no devices in the subgroup will
#: receive this deployment.
#: A newer deployment for this subgroup has been created and no devices in the
#: subgroup will receive this deployment.
INACTIVE = "Inactive"
#: The subgroup deployment has been canceled and no devices will receive it.
CANCELED = "Canceled"
Expand All @@ -62,6 +64,16 @@ class DeviceHealthState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
#: Agent is in an unhealthy state
UNHEALTHY = "unhealthy"

class DownloadSecurity(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The protocol the device should use when downloading the update payload.
Defaults to "https".
"""

#: Download update payload over HTTPS.
HTTPS = "https"
#: Download update payload over HTTP.
HTTP = "http"

class GroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported group types.
"""
Expand Down Expand Up @@ -95,7 +107,9 @@ class OperationFilterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Operation status filter.
"""

#: Running
RUNNING = "Running"
#: NotStarted
NOT_STARTED = "NotStarted"

class OperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta):
Expand All @@ -116,6 +130,6 @@ class StepType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""

#: Step type that performs code execution.
INLINE = "Inline"
INLINE = "inline"
#: Step type that installs another update.
REFERENCE = "Reference"
REFERENCE = "reference"
Loading
Loading