diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/__init__.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/__init__.py new file mode 100644 index 000000000000..80cd2ef96536 --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from ._configuration import DeviceUpdateClientConfiguration +from ._device_update_client import DeviceUpdateClient +__all__ = ['DeviceUpdateClient', 'DeviceUpdateClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/_configuration.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/_configuration.py new file mode 100644 index 000000000000..96e875e4c6aa --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/_configuration.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from msrest import Configuration + +from .version import VERSION + + +class DeviceUpdateClientConfiguration(Configuration): + """Configuration for DeviceUpdateClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param account_endpoint: Account endpoint. + :type account_endpoint: str + :param instance_id: Account instance identifier. + :type instance_id: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, account_endpoint, instance_id, credentials): + + if account_endpoint is None: + raise ValueError("Parameter 'account_endpoint' must not be None.") + if instance_id is None: + raise ValueError("Parameter 'instance_id' must not be None.") + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + base_url = 'https://{accountEndpoint}' + + super(DeviceUpdateClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-deviceupdate/{}'.format(VERSION)) + + self.account_endpoint = account_endpoint + self.instance_id = instance_id + self.credentials = credentials diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/_device_update_client.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/_device_update_client.py new file mode 100644 index 000000000000..d1061236b541 --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/_device_update_client.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import DeviceUpdateClientConfiguration +from msrest.exceptions import HttpOperationError +from .operations import UpdatesOperations +from .operations import DevicesOperations +from .operations import DeploymentsOperations +from . import models + + +class DeviceUpdateClient(SDKClient): + """Device Update for IoT Hub is an Azure service that enables customers to publish update for their IoT devices to the cloud, and then deploy that update to their devices (approve updates to groups of devices managed and provisioned in IoT Hub). It leverages the proven security and reliability of the Windows Update platform, optimized for IoT devices. It works globally and 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 config: Configuration for client. + :vartype config: DeviceUpdateClientConfiguration + + :ivar updates: Updates operations + :vartype updates: azure.deviceupdate.operations.UpdatesOperations + :ivar devices: Devices operations + :vartype devices: azure.deviceupdate.operations.DevicesOperations + :ivar deployments: Deployments operations + :vartype deployments: azure.deviceupdate.operations.DeploymentsOperations + + :param account_endpoint: Account endpoint. + :type account_endpoint: str + :param instance_id: Account instance identifier. + :type instance_id: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, account_endpoint, instance_id, credentials): + + self.config = DeviceUpdateClientConfiguration(account_endpoint, instance_id, credentials) + super(DeviceUpdateClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2020-09-01' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.updates = UpdatesOperations( + self._client, self.config, self._serialize, self._deserialize) + self.devices = DevicesOperations( + self._client, self.config, self._serialize, self._deserialize) + self.deployments = DeploymentsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/__init__.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/__init__.py new file mode 100644 index 000000000000..1718078ba8e9 --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/__init__.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import AccessCondition + from ._models_py3 import AccountOptions + from ._models_py3 import Compatibility + from ._models_py3 import Deployment + from ._models_py3 import DeploymentDeviceState + from ._models_py3 import DeploymentDeviceStatesFilter + from ._models_py3 import DeploymentFilter + from ._models_py3 import DeploymentStatus + from ._models_py3 import Device + from ._models_py3 import DeviceClass + from ._models_py3 import DeviceFilter + from ._models_py3 import DeviceTag + from ._models_py3 import Error + from ._models_py3 import File + from ._models_py3 import FileImportMetadata + from ._models_py3 import Group + from ._models_py3 import GroupBestUpdatesFilter + from ._models_py3 import ImportManifestMetadata + from ._models_py3 import ImportUpdateInput + from ._models_py3 import InnerError + from ._models_py3 import Operation + from ._models_py3 import OperationFilter + from ._models_py3 import PageableListOfDeploymentDeviceStates + from ._models_py3 import PageableListOfDeployments + from ._models_py3 import PageableListOfDeviceClasses + from ._models_py3 import PageableListOfDevices + from ._models_py3 import PageableListOfDeviceTags + from ._models_py3 import PageableListOfGroups + from ._models_py3 import PageableListOfOperations + from ._models_py3 import PageableListOfStrings + from ._models_py3 import PageableListOfUpdatableDevices + from ._models_py3 import PageableListOfUpdateIds + from ._models_py3 import UpdatableDevices + from ._models_py3 import Update + from ._models_py3 import UpdateCompliance + from ._models_py3 import UpdateId +except (SyntaxError, ImportError): + from ._models import AccessCondition + from ._models import AccountOptions + from ._models import Compatibility + from ._models import Deployment + from ._models import DeploymentDeviceState + from ._models import DeploymentDeviceStatesFilter + from ._models import DeploymentFilter + from ._models import DeploymentStatus + from ._models import Device + from ._models import DeviceClass + from ._models import DeviceFilter + from ._models import DeviceTag + from ._models import Error + from ._models import File + from ._models import FileImportMetadata + from ._models import Group + from ._models import GroupBestUpdatesFilter + from ._models import ImportManifestMetadata + from ._models import ImportUpdateInput + from ._models import InnerError + from ._models import Operation + from ._models import OperationFilter + from ._models import PageableListOfDeploymentDeviceStates + from ._models import PageableListOfDeployments + from ._models import PageableListOfDeviceClasses + from ._models import PageableListOfDevices + from ._models import PageableListOfDeviceTags + from ._models import PageableListOfGroups + from ._models import PageableListOfOperations + from ._models import PageableListOfStrings + from ._models import PageableListOfUpdatableDevices + from ._models import PageableListOfUpdateIds + from ._models import UpdatableDevices + from ._models import Update + from ._models import UpdateCompliance + from ._models import UpdateId +from ._device_update_client_enums import ( + DeploymentState, + DeploymentType, + DeviceDeploymentState, + DeviceGroupType, + DeviceState, + GroupType, + OperationFilterStatus, + OperationStatus, +) + +__all__ = [ + 'AccessCondition', + 'AccountOptions', + 'Compatibility', + 'Deployment', + 'DeploymentDeviceState', + 'DeploymentDeviceStatesFilter', + 'DeploymentFilter', + 'DeploymentStatus', + 'Device', + 'DeviceClass', + 'DeviceFilter', + 'DeviceTag', + 'Error', + 'File', + 'FileImportMetadata', + 'Group', + 'GroupBestUpdatesFilter', + 'ImportManifestMetadata', + 'ImportUpdateInput', + 'InnerError', + 'Operation', + 'OperationFilter', + 'PageableListOfDeploymentDeviceStates', + 'PageableListOfDeployments', + 'PageableListOfDeviceClasses', + 'PageableListOfDevices', + 'PageableListOfDeviceTags', + 'PageableListOfGroups', + 'PageableListOfOperations', + 'PageableListOfStrings', + 'PageableListOfUpdatableDevices', + 'PageableListOfUpdateIds', + 'UpdatableDevices', + 'Update', + 'UpdateCompliance', + 'UpdateId', + 'OperationStatus', + 'DeviceDeploymentState', + 'GroupType', + 'DeploymentType', + 'DeviceGroupType', + 'DeploymentState', + 'OperationFilterStatus', + 'DeviceState', +] diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/_device_update_client_enums.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/_device_update_client_enums.py new file mode 100644 index 000000000000..3e65d3381bac --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/_device_update_client_enums.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from enum import Enum + + +class OperationStatus(str, Enum): + + undefined = "Undefined" #: Undefined operation status. + not_started = "NotStarted" #: Background operation created but not started yet. + running = "Running" #: Background operation is currently running. + succeeded = "Succeeded" #: Background operation finished with success. + failed = "Failed" #: Background operation finished with failure. + + +class DeviceDeploymentState(str, Enum): + + succeeded = "Succeeded" #: Deployment has completed with success. + in_progress = "InProgress" #: Deployment is in progress. + failed = "Failed" #: Deployment has completed with failure. + canceled = "Canceled" #: Deployment was canceled. + incompatible = "Incompatible" #: Deployment is not compatible with the device. + + +class GroupType(str, Enum): + + io_thub_tag = "IoTHubTag" #: IoT Hub tag based group. + + +class DeploymentType(str, Enum): + + complete = "Complete" #: A complete deployment including download, install, and apply actions. + download = "Download" #: A download-only deployment that does not include any install or apply actions. Not currently supported. + install = "Install" #: An install-only rollout that does not include any download actions, only install and complete. Not currently supported. + + +class DeviceGroupType(str, Enum): + + all = "All" #: The deployment should be sent to all devices in the device class. + devices = "Devices" #: The deployment should be sent to the list of devices in the device group definition. + device_group_definitions = "DeviceGroupDefinitions" #: The deployment should be sent to the list of devices returned by the union of all the device group definition queries. + + +class DeploymentState(str, Enum): + + active = "Active" #: The deployment can be sent to devices targeted in the deployment. + superseded = "Superseded" #: A newer deployment with the same targeting exists and no devices will receive this deployment. + canceled = "Canceled" #: The deployment has been canceled and no devices will receive it. + + +class OperationFilterStatus(str, Enum): + + running = "Running" + not_started = "NotStarted" + + +class DeviceState(str, Enum): + + not_started = "NotStarted" #: Not started (or uninitialized) + incompatible = "Incompatible" #: Deployment incompatible for this device. + already_in_deployment = "AlreadyInDeployment" #: Another Deployment is underway for this device. + canceled = "Canceled" #: Deployment has been canceled for this device. + in_progress = "InProgress" #: Deployment underway. + failed = "Failed" #: Deployment failed. + succeeded = "Succeeded" #: Deployment completed successfully. diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/_models.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/_models.py new file mode 100644 index 000000000000..e7c36e9488b0 --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/_models.py @@ -0,0 +1,1174 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class AccessCondition(Model): + """Additional parameters for a set of operations, such as: Updates_get_update, + Updates_get_file, Updates_get_operation. + + :param if_none_match: Defines the If-None-Match condition. The operation + will be performed only if the ETag on the server does not match this + value. + :type if_none_match: str + """ + + _attribute_map = { + 'if_none_match': {'key': '', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AccessCondition, self).__init__(**kwargs) + self.if_none_match = kwargs.get('if_none_match', None) + + +class AccountOptions(Model): + """Additional parameters for a set of operations. + + All required parameters must be populated in order to send to Azure. + + :param instance_id: Required. Account instance identifier. + :type instance_id: str + """ + + _validation = { + 'instance_id': {'required': True}, + } + + _attribute_map = { + 'instance_id': {'key': '', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AccountOptions, self).__init__(**kwargs) + self.instance_id = kwargs.get('instance_id', None) + + +class Compatibility(Model): + """Update compatibility information. + + All required parameters must be populated in order to send to Azure. + + :param device_manufacturer: Required. The manufacturer of device the + update is compatible with. + :type device_manufacturer: str + :param device_model: Required. The model of device the update is + compatible with. + :type device_model: str + """ + + _validation = { + 'device_manufacturer': {'required': True}, + 'device_model': {'required': True}, + } + + _attribute_map = { + 'device_manufacturer': {'key': 'deviceManufacturer', 'type': 'str'}, + 'device_model': {'key': 'deviceModel', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Compatibility, self).__init__(**kwargs) + self.device_manufacturer = kwargs.get('device_manufacturer', None) + self.device_model = kwargs.get('device_model', None) + + +class Deployment(Model): + """Deployment metadata. + + All required parameters must be populated in order to send to Azure. + + :param deployment_id: Required. Gets or sets the deployment identifier. + :type deployment_id: str + :param deployment_type: Required. Gets or sets the deployment type. + Possible values include: 'Complete', 'Download', 'Install' + :type deployment_type: str or ~azure.deviceupdate.models.DeploymentType + :param device_class_id: Gets or sets the device class identifier. + :type device_class_id: str + :param start_date_time: Required. Gets or sets the Deployment start + datetime. + :type start_date_time: datetime + :param device_group_type: Required. Gets or sets the device group type. + Possible values include: 'All', 'Devices', 'DeviceGroupDefinitions' + :type device_group_type: str or ~azure.deviceupdate.models.DeviceGroupType + :param device_group_definition: Required. Gets or sets the device group + definition. + :type device_group_definition: list[str] + :param update_id: Required. Update identity. + :type update_id: ~azure.deviceupdate.models.UpdateId + :param is_canceled: Boolean flag indicating whether the deployment was + canceled. + :type is_canceled: bool + :param is_retried: Boolean flag indicating whether the deployment has been + retried. + :type is_retried: bool + :param is_completed: Boolean flag indicating whether the deployment was + completed. + :type is_completed: bool + """ + + _validation = { + 'deployment_id': {'required': True}, + 'deployment_type': {'required': True}, + 'start_date_time': {'required': True}, + 'device_group_type': {'required': True}, + 'device_group_definition': {'required': True}, + 'update_id': {'required': True}, + } + + _attribute_map = { + 'deployment_id': {'key': 'deploymentId', 'type': 'str'}, + 'deployment_type': {'key': 'deploymentType', 'type': 'str'}, + 'device_class_id': {'key': 'deviceClassId', 'type': 'str'}, + 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, + 'device_group_type': {'key': 'deviceGroupType', 'type': 'str'}, + 'device_group_definition': {'key': 'deviceGroupDefinition', 'type': '[str]'}, + 'update_id': {'key': 'updateId', 'type': 'UpdateId'}, + 'is_canceled': {'key': 'isCanceled', 'type': 'bool'}, + 'is_retried': {'key': 'isRetried', 'type': 'bool'}, + 'is_completed': {'key': 'isCompleted', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(Deployment, self).__init__(**kwargs) + self.deployment_id = kwargs.get('deployment_id', None) + self.deployment_type = kwargs.get('deployment_type', None) + self.device_class_id = kwargs.get('device_class_id', None) + self.start_date_time = kwargs.get('start_date_time', None) + self.device_group_type = kwargs.get('device_group_type', None) + self.device_group_definition = kwargs.get('device_group_definition', None) + self.update_id = kwargs.get('update_id', None) + self.is_canceled = kwargs.get('is_canceled', None) + self.is_retried = kwargs.get('is_retried', None) + self.is_completed = kwargs.get('is_completed', None) + + +class DeploymentDeviceState(Model): + """Deployment device status. + + All required parameters must be populated in order to send to Azure. + + :param device_id: Required. Device identity. + :type device_id: str + :param retry_count: Required. The number of times this deployment has been + retried on this device. + :type retry_count: int + :param moved_on_to_new_deployment: Required. Boolean flag indicating + whether this device is in a newer deployment and can no longer retry this + deployment. + :type moved_on_to_new_deployment: bool + :param device_state: Required. Deployment device state. Possible values + include: 'Succeeded', 'InProgress', 'Failed', 'Canceled', 'Incompatible' + :type device_state: str or + ~azure.deviceupdate.models.DeviceDeploymentState + """ + + _validation = { + 'device_id': {'required': True}, + 'retry_count': {'required': True}, + 'moved_on_to_new_deployment': {'required': True}, + 'device_state': {'required': True}, + } + + _attribute_map = { + 'device_id': {'key': 'deviceId', 'type': 'str'}, + 'retry_count': {'key': 'retryCount', 'type': 'int'}, + 'moved_on_to_new_deployment': {'key': 'movedOnToNewDeployment', 'type': 'bool'}, + 'device_state': {'key': 'deviceState', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(DeploymentDeviceState, self).__init__(**kwargs) + self.device_id = kwargs.get('device_id', None) + self.retry_count = kwargs.get('retry_count', None) + self.moved_on_to_new_deployment = kwargs.get('moved_on_to_new_deployment', None) + self.device_state = kwargs.get('device_state', None) + + +class DeploymentDeviceStatesFilter(Model): + """Deployment device state filter. + + :param device_id: Device Identifier. + :type device_id: str + :param device_state: The deployment device state. Possible values include: + 'NotStarted', 'Incompatible', 'AlreadyInDeployment', 'Canceled', + 'InProgress', 'Failed', 'Succeeded' + :type device_state: str or ~azure.deviceupdate.models.DeviceState + """ + + _attribute_map = { + 'device_id': {'key': 'deviceId', 'type': 'str'}, + 'device_state': {'key': 'deviceState', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(DeploymentDeviceStatesFilter, self).__init__(**kwargs) + self.device_id = kwargs.get('device_id', None) + self.device_state = kwargs.get('device_state', None) + + +class DeploymentFilter(Model): + """Deployment filter. + + :param provider: Update provider. + :type provider: str + :param name: Update name. + :type name: str + :param version: Update version. + :type version: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(DeploymentFilter, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.name = kwargs.get('name', None) + self.version = kwargs.get('version', None) + + +class DeploymentStatus(Model): + """Deployment status metadata. + + All required parameters must be populated in order to send to Azure. + + :param deployment_state: Required. Gets or sets the state of the + deployment. Possible values include: 'Active', 'Superseded', 'Canceled' + :type deployment_state: str or ~azure.deviceupdate.models.DeploymentState + :param total_devices: Gets or sets the total number of devices in the + deployment. + :type total_devices: int + :param devices_incompatible_count: Gets or sets the number of incompatible + devices in the deployment. + :type devices_incompatible_count: int + :param devices_in_progress_count: Gets or sets the number of devices that + are currently in deployment. + :type devices_in_progress_count: int + :param devices_completed_failed_count: Gets or sets the number of devices + that have completed deployment with a failure. + :type devices_completed_failed_count: int + :param devices_completed_succeeded_count: Gets or sets the number of + devices which have successfully completed deployment. + :type devices_completed_succeeded_count: int + :param devices_canceled_count: Gets or sets the number of devices which + have had their deployment canceled. + :type devices_canceled_count: int + """ + + _validation = { + 'deployment_state': {'required': True}, + } + + _attribute_map = { + 'deployment_state': {'key': 'deploymentState', 'type': 'str'}, + 'total_devices': {'key': 'totalDevices', 'type': 'int'}, + 'devices_incompatible_count': {'key': 'devicesIncompatibleCount', 'type': 'int'}, + 'devices_in_progress_count': {'key': 'devicesInProgressCount', 'type': 'int'}, + 'devices_completed_failed_count': {'key': 'devicesCompletedFailedCount', 'type': 'int'}, + 'devices_completed_succeeded_count': {'key': 'devicesCompletedSucceededCount', 'type': 'int'}, + 'devices_canceled_count': {'key': 'devicesCanceledCount', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(DeploymentStatus, self).__init__(**kwargs) + self.deployment_state = kwargs.get('deployment_state', None) + self.total_devices = kwargs.get('total_devices', None) + self.devices_incompatible_count = kwargs.get('devices_incompatible_count', None) + self.devices_in_progress_count = kwargs.get('devices_in_progress_count', None) + self.devices_completed_failed_count = kwargs.get('devices_completed_failed_count', None) + self.devices_completed_succeeded_count = kwargs.get('devices_completed_succeeded_count', None) + self.devices_canceled_count = kwargs.get('devices_canceled_count', None) + + +class Device(Model): + """Device metadata. + + All required parameters must be populated in order to send to Azure. + + :param device_id: Required. Device identity. + :type device_id: str + :param device_class_id: Required. Device class identity. + :type device_class_id: str + :param manufacturer: Required. Device manufacturer. + :type manufacturer: str + :param model: Required. Device model. + :type model: str + :param group_id: Device group identity. + :type group_id: str + :param last_attempted_update_id: Update identity. + :type last_attempted_update_id: ~azure.deviceupdate.models.UpdateId + :param deployment_status: State of the device in its last deployment. + Possible values include: 'Succeeded', 'InProgress', 'Failed', 'Canceled', + 'Incompatible' + :type deployment_status: str or + ~azure.deviceupdate.models.DeviceDeploymentState + :param installed_update_id: Update identity. + :type installed_update_id: ~azure.deviceupdate.models.UpdateId + :param on_latest_update: Required. Boolean flag indicating whether the + latest update is installed on the device + :type on_latest_update: bool + :param last_deployment_id: The deployment identifier for the last + deployment to the device + :type last_deployment_id: str + """ + + _validation = { + 'device_id': {'required': True}, + 'device_class_id': {'required': True}, + 'manufacturer': {'required': True}, + 'model': {'required': True}, + 'on_latest_update': {'required': True}, + } + + _attribute_map = { + 'device_id': {'key': 'deviceId', 'type': 'str'}, + 'device_class_id': {'key': 'deviceClassId', 'type': 'str'}, + 'manufacturer': {'key': 'manufacturer', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'group_id': {'key': 'groupId', 'type': 'str'}, + 'last_attempted_update_id': {'key': 'lastAttemptedUpdateId', 'type': 'UpdateId'}, + 'deployment_status': {'key': 'deploymentStatus', 'type': 'str'}, + 'installed_update_id': {'key': 'installedUpdateId', 'type': 'UpdateId'}, + 'on_latest_update': {'key': 'onLatestUpdate', 'type': 'bool'}, + 'last_deployment_id': {'key': 'lastDeploymentId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Device, self).__init__(**kwargs) + self.device_id = kwargs.get('device_id', None) + self.device_class_id = kwargs.get('device_class_id', None) + self.manufacturer = kwargs.get('manufacturer', None) + self.model = kwargs.get('model', None) + self.group_id = kwargs.get('group_id', None) + self.last_attempted_update_id = kwargs.get('last_attempted_update_id', None) + self.deployment_status = kwargs.get('deployment_status', None) + self.installed_update_id = kwargs.get('installed_update_id', None) + self.on_latest_update = kwargs.get('on_latest_update', None) + self.last_deployment_id = kwargs.get('last_deployment_id', None) + + +class DeviceClass(Model): + """Device class metadata. + + All required parameters must be populated in order to send to Azure. + + :param device_class_id: Required. The device class identifier. + :type device_class_id: str + :param manufacturer: Required. Device manufacturer + :type manufacturer: str + :param model: Required. Device model. + :type model: str + :param best_compatible_update_id: Required. Update identity. + :type best_compatible_update_id: ~azure.deviceupdate.models.UpdateId + """ + + _validation = { + 'device_class_id': {'required': True}, + 'manufacturer': {'required': True}, + 'model': {'required': True}, + 'best_compatible_update_id': {'required': True}, + } + + _attribute_map = { + 'device_class_id': {'key': 'deviceClassId', 'type': 'str'}, + 'manufacturer': {'key': 'manufacturer', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'best_compatible_update_id': {'key': 'bestCompatibleUpdateId', 'type': 'UpdateId'}, + } + + def __init__(self, **kwargs): + super(DeviceClass, self).__init__(**kwargs) + self.device_class_id = kwargs.get('device_class_id', None) + self.manufacturer = kwargs.get('manufacturer', None) + self.model = kwargs.get('model', None) + self.best_compatible_update_id = kwargs.get('best_compatible_update_id', None) + + +class DeviceFilter(Model): + """Operation status filter. + + :param group_id: Device group identifier. + :type group_id: str + """ + + _attribute_map = { + 'group_id': {'key': 'groupId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(DeviceFilter, self).__init__(**kwargs) + self.group_id = kwargs.get('group_id', None) + + +class DeviceTag(Model): + """Device tag properties. + + All required parameters must be populated in order to send to Azure. + + :param tag_name: Required. Tag name. + :type tag_name: str + :param device_count: Required. Number of devices with this tag. + :type device_count: int + """ + + _validation = { + 'tag_name': {'required': True}, + 'device_count': {'required': True}, + } + + _attribute_map = { + 'tag_name': {'key': 'tagName', 'type': 'str'}, + 'device_count': {'key': 'deviceCount', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(DeviceTag, self).__init__(**kwargs) + self.tag_name = kwargs.get('tag_name', None) + self.device_count = kwargs.get('device_count', None) + + +class Error(Model): + """Error details. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. Server defined error code. + :type code: str + :param message: Required. A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of errors that led to the reported error. + :type details: list[~azure.deviceupdate.models.Error] + :param innererror: An object containing more specific information than the + current object about the error. + :type innererror: ~azure.deviceupdate.models.InnerError + :param occurred_date_time: Date and time in UTC when the error occurred. + :type occurred_date_time: datetime + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'innererror': {'key': 'innererror', 'type': 'InnerError'}, + 'occurred_date_time': {'key': 'occurredDateTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(Error, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + self.details = kwargs.get('details', None) + self.innererror = kwargs.get('innererror', None) + self.occurred_date_time = kwargs.get('occurred_date_time', None) + + +class File(Model): + """Update file metadata. + + All required parameters must be populated in order to send to Azure. + + :param file_id: Required. File identity, generated by server at import + time. + :type file_id: str + :param file_name: Required. File name. + :type file_name: str + :param size_in_bytes: Required. File size in number of bytes. + :type size_in_bytes: long + :param hashes: Required. Mapping of hashing algorithm to base64 encoded + hash values. + :type hashes: dict[str, str] + :param mime_type: File MIME type. + :type mime_type: str + :param etag: File ETag. + :type etag: str + """ + + _validation = { + 'file_id': {'required': True}, + 'file_name': {'required': True}, + 'size_in_bytes': {'required': True}, + 'hashes': {'required': True}, + } + + _attribute_map = { + 'file_id': {'key': 'fileId', 'type': 'str'}, + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'size_in_bytes': {'key': 'sizeInBytes', 'type': 'long'}, + 'hashes': {'key': 'hashes', 'type': '{str}'}, + 'mime_type': {'key': 'mimeType', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(File, self).__init__(**kwargs) + self.file_id = kwargs.get('file_id', None) + self.file_name = kwargs.get('file_name', None) + self.size_in_bytes = kwargs.get('size_in_bytes', None) + self.hashes = kwargs.get('hashes', None) + self.mime_type = kwargs.get('mime_type', None) + self.etag = kwargs.get('etag', None) + + +class FileImportMetadata(Model): + """Metadata describing an update file. + + All required parameters must be populated in order to send to Azure. + + :param filename: Required. Update file name as specified inside import + manifest. + :type filename: str + :param url: Required. Azure Blob location from which the update file can + be downloaded by Device Update for IoT Hub. This is typically a read-only + SAS-protected blob URL with an expiration set to at least 4 hours. + :type url: str + """ + + _validation = { + 'filename': {'required': True}, + 'url': {'required': True}, + } + + _attribute_map = { + 'filename': {'key': 'filename', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(FileImportMetadata, self).__init__(**kwargs) + self.filename = kwargs.get('filename', None) + self.url = kwargs.get('url', None) + + +class Group(Model): + """Group details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param group_id: Required. Group identity. + :type group_id: str + :ivar group_type: Required. Group type. Default value: "IoTHubTag" . + :vartype group_type: str + :param tags: Required. IoT Hub tags. + :type tags: list[str] + :param created_date_time: Required. Date and time when the update was + created. + :type created_date_time: str + :param device_count: The number of devices in the group. + :type device_count: int + """ + + _validation = { + 'group_id': {'required': True}, + 'group_type': {'required': True, 'constant': True}, + 'tags': {'required': True}, + 'created_date_time': {'required': True}, + } + + _attribute_map = { + 'group_id': {'key': 'groupId', 'type': 'str'}, + 'group_type': {'key': 'groupType', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '[str]'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'str'}, + 'device_count': {'key': 'deviceCount', 'type': 'int'}, + } + + group_type = "IoTHubTag" + + def __init__(self, **kwargs): + super(Group, self).__init__(**kwargs) + self.group_id = kwargs.get('group_id', None) + self.tags = kwargs.get('tags', None) + self.created_date_time = kwargs.get('created_date_time', None) + self.device_count = kwargs.get('device_count', None) + + +class GroupBestUpdatesFilter(Model): + """Group best updates filter. + + :param provider: Update provider. + :type provider: str + :param name: Update name. + :type name: str + :param version: Update version. + :type version: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(GroupBestUpdatesFilter, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.name = kwargs.get('name', None) + self.version = kwargs.get('version', None) + + +class ImportManifestMetadata(Model): + """Metadata describing the import manifest, a document which describes the + files and other metadata about an update version. + + All required parameters must be populated in order to send to Azure. + + :param url: Required. Azure Blob location from which the import manifest + can be downloaded by Device Update for IoT Hub. This is typically a + read-only SAS-protected blob URL with an expiration set to at least 4 + hours. + :type url: str + :param size_in_bytes: Required. File size in number of bytes. + :type size_in_bytes: long + :param hashes: Required. A JSON object containing the hash(es) of the + file. At least SHA256 hash is required. This object can be thought of as a + set of key-value pairs where the key is the hash algorithm, and the value + is the hash of the file calculated using that algorithm. + :type hashes: dict[str, str] + """ + + _validation = { + 'url': {'required': True}, + 'size_in_bytes': {'required': True}, + 'hashes': {'required': True}, + } + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'size_in_bytes': {'key': 'sizeInBytes', 'type': 'long'}, + 'hashes': {'key': 'hashes', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(ImportManifestMetadata, self).__init__(**kwargs) + self.url = kwargs.get('url', None) + self.size_in_bytes = kwargs.get('size_in_bytes', None) + self.hashes = kwargs.get('hashes', None) + + +class ImportUpdateInput(Model): + """Import update input metadata. + + All required parameters must be populated in order to send to Azure. + + :param import_manifest: Required. Import manifest metadata like source + URL, file size/hashes, etc. + :type import_manifest: ~azure.deviceupdate.models.ImportManifestMetadata + :param files: Required. One or more update file properties like filename + and source URL. + :type files: list[~azure.deviceupdate.models.FileImportMetadata] + """ + + _validation = { + 'import_manifest': {'required': True}, + 'files': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'import_manifest': {'key': 'importManifest', 'type': 'ImportManifestMetadata'}, + 'files': {'key': 'files', 'type': '[FileImportMetadata]'}, + } + + def __init__(self, **kwargs): + super(ImportUpdateInput, self).__init__(**kwargs) + self.import_manifest = kwargs.get('import_manifest', None) + self.files = kwargs.get('files', None) + + +class InnerError(Model): + """An object containing more specific information than the current object + about the error. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. A more specific error code than what was provided + by the containing error. + :type code: str + :param message: A human-readable representation of the error. + :type message: str + :param error_detail: The internal error or exception message. + :type error_detail: str + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: ~azure.deviceupdate.models.InnerError + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'error_detail': {'key': 'errorDetail', 'type': 'str'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerError'}, + } + + def __init__(self, **kwargs): + super(InnerError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.error_detail = kwargs.get('error_detail', None) + self.inner_error = kwargs.get('inner_error', None) + + +class Operation(Model): + """Operation metadata. + + All required parameters must be populated in order to send to Azure. + + :param operation_id: Required. Operation Id. + :type operation_id: str + :param status: Required. Operation status. Possible values include: + 'Undefined', 'NotStarted', 'Running', 'Succeeded', 'Failed' + :type status: str or ~azure.deviceupdate.models.OperationStatus + :param update_id: The identity of update being imported or deleted. For + import, this property will only be populated after import manifest is + processed successfully. + :type update_id: ~azure.deviceupdate.models.UpdateId + :param resource_location: Location of the imported update when operation + is successful. + :type resource_location: str + :param error: Operation error encountered, if any. + :type error: ~azure.deviceupdate.models.Error + :param trace_id: Operation correlation identity that can used by Microsoft + Support for troubleshooting. + :type trace_id: str + :param last_action_date_time: Required. Date and time in UTC when the + operation status was last updated. + :type last_action_date_time: datetime + :param created_date_time: Required. Date and time in UTC when the + operation was created. + :type created_date_time: datetime + :param etag: Operation ETag. + :type etag: str + """ + + _validation = { + 'operation_id': {'required': True}, + 'status': {'required': True}, + 'last_action_date_time': {'required': True}, + 'created_date_time': {'required': True}, + } + + _attribute_map = { + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'update_id': {'key': 'updateId', 'type': 'UpdateId'}, + 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'Error'}, + 'trace_id': {'key': 'traceId', 'type': 'str'}, + 'last_action_date_time': {'key': 'lastActionDateTime', 'type': 'iso-8601'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Operation, self).__init__(**kwargs) + self.operation_id = kwargs.get('operation_id', None) + self.status = kwargs.get('status', None) + self.update_id = kwargs.get('update_id', None) + self.resource_location = kwargs.get('resource_location', None) + self.error = kwargs.get('error', None) + self.trace_id = kwargs.get('trace_id', None) + self.last_action_date_time = kwargs.get('last_action_date_time', None) + self.created_date_time = kwargs.get('created_date_time', None) + self.etag = kwargs.get('etag', None) + + +class OperationFilter(Model): + """Operation status filter. + + :param status: Operation status filter. Possible values include: + 'Running', 'NotStarted' + :type status: str or ~azure.deviceupdate.models.OperationFilterStatus + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(OperationFilter, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + + +class PageableListOfDeploymentDeviceStates(Model): + """The list of deployment device states. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.DeploymentDeviceState] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentDeviceState]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfDeploymentDeviceStates, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PageableListOfDeployments(Model): + """The list of deployments. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.Deployment] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Deployment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfDeployments, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PageableListOfDeviceClasses(Model): + """The list of device classes. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.DeviceClass] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeviceClass]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfDeviceClasses, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PageableListOfDevices(Model): + """The list of devices. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.Device] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Device]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfDevices, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PageableListOfDeviceTags(Model): + """The list of device tags. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.DeviceTag] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeviceTag]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfDeviceTags, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PageableListOfGroups(Model): + """The list of groups. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.Group] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Group]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfGroups, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PageableListOfOperations(Model): + """The list of operations with server paging support. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.Operation] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfOperations, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PageableListOfStrings(Model): + """The list of strings with server paging support. + + :param value: The collection of pageable items. + :type value: list[str] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[str]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfStrings, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PageableListOfUpdatableDevices(Model): + """The list of updatable devices. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.UpdatableDevices] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UpdatableDevices]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfUpdatableDevices, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PageableListOfUpdateIds(Model): + """The list of update identities. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.UpdateId] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UpdateId]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PageableListOfUpdateIds, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class UpdatableDevices(Model): + """Update identifier and the number of devices for which the update is + applicable. + + All required parameters must be populated in order to send to Azure. + + :param update_id: Required. Update identity. + :type update_id: ~azure.deviceupdate.models.UpdateId + :param device_count: Required. Total number of devices for which the + update is applicable. + :type device_count: int + """ + + _validation = { + 'update_id': {'required': True}, + 'device_count': {'required': True}, + } + + _attribute_map = { + 'update_id': {'key': 'updateId', 'type': 'UpdateId'}, + 'device_count': {'key': 'deviceCount', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(UpdatableDevices, self).__init__(**kwargs) + self.update_id = kwargs.get('update_id', None) + self.device_count = kwargs.get('device_count', None) + + +class Update(Model): + """Update metadata. + + All required parameters must be populated in order to send to Azure. + + :param update_id: Required. Update identity. + :type update_id: ~azure.deviceupdate.models.UpdateId + :param update_type: Required. Update type. + :type update_type: str + :param installed_criteria: Required. String interpreted by Device Update + client to determine if the update is installed on the device. + :type installed_criteria: str + :param compatibility: Required. List of update compatibility information. + :type compatibility: list[~azure.deviceupdate.models.Compatibility] + :param manifest_version: Required. Schema version of manifest used to + import the update. + :type manifest_version: str + :param imported_date_time: Required. Date and time in UTC when the update + was imported. + :type imported_date_time: datetime + :param created_date_time: Required. Date and time in UTC when the update + was created. + :type created_date_time: datetime + :param etag: Update ETag. + :type etag: str + """ + + _validation = { + 'update_id': {'required': True}, + 'update_type': {'required': True}, + 'installed_criteria': {'required': True}, + 'compatibility': {'required': True, 'min_items': 1}, + 'manifest_version': {'required': True}, + 'imported_date_time': {'required': True}, + 'created_date_time': {'required': True}, + } + + _attribute_map = { + 'update_id': {'key': 'updateId', 'type': 'UpdateId'}, + 'update_type': {'key': 'updateType', 'type': 'str'}, + 'installed_criteria': {'key': 'installedCriteria', 'type': 'str'}, + 'compatibility': {'key': 'compatibility', 'type': '[Compatibility]'}, + 'manifest_version': {'key': 'manifestVersion', 'type': 'str'}, + 'imported_date_time': {'key': 'importedDateTime', 'type': 'iso-8601'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Update, self).__init__(**kwargs) + self.update_id = kwargs.get('update_id', None) + self.update_type = kwargs.get('update_type', None) + self.installed_criteria = kwargs.get('installed_criteria', None) + self.compatibility = kwargs.get('compatibility', None) + self.manifest_version = kwargs.get('manifest_version', None) + self.imported_date_time = kwargs.get('imported_date_time', None) + self.created_date_time = kwargs.get('created_date_time', None) + self.etag = kwargs.get('etag', None) + + +class UpdateCompliance(Model): + """Update compliance information. + + All required parameters must be populated in order to send to Azure. + + :param total_device_count: Required. Total number of devices. + :type total_device_count: int + :param on_latest_update_device_count: Required. Number of devices on the + latest update. + :type on_latest_update_device_count: int + :param new_updates_available_device_count: Required. Number of devices + with a newer update available. + :type new_updates_available_device_count: int + :param updates_in_progress_device_count: Required. Number of devices with + update in-progress. + :type updates_in_progress_device_count: int + """ + + _validation = { + 'total_device_count': {'required': True}, + 'on_latest_update_device_count': {'required': True}, + 'new_updates_available_device_count': {'required': True}, + 'updates_in_progress_device_count': {'required': True}, + } + + _attribute_map = { + 'total_device_count': {'key': 'totalDeviceCount', 'type': 'int'}, + 'on_latest_update_device_count': {'key': 'onLatestUpdateDeviceCount', 'type': 'int'}, + 'new_updates_available_device_count': {'key': 'newUpdatesAvailableDeviceCount', 'type': 'int'}, + 'updates_in_progress_device_count': {'key': 'updatesInProgressDeviceCount', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(UpdateCompliance, self).__init__(**kwargs) + self.total_device_count = kwargs.get('total_device_count', None) + self.on_latest_update_device_count = kwargs.get('on_latest_update_device_count', None) + self.new_updates_available_device_count = kwargs.get('new_updates_available_device_count', None) + self.updates_in_progress_device_count = kwargs.get('updates_in_progress_device_count', None) + + +class UpdateId(Model): + """Update identifier. + + All required parameters must be populated in order to send to Azure. + + :param provider: Required. Update provider. + :type provider: str + :param name: Required. Update name. + :type name: str + :param version: Required. Update version. + :type version: str + """ + + _validation = { + 'provider': {'required': True}, + 'name': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(UpdateId, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.name = kwargs.get('name', None) + self.version = kwargs.get('version', None) diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/_models_py3.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/_models_py3.py new file mode 100644 index 000000000000..74facaec0b3d --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/models/_models_py3.py @@ -0,0 +1,1174 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class AccessCondition(Model): + """Additional parameters for a set of operations, such as: Updates_get_update, + Updates_get_file, Updates_get_operation. + + :param if_none_match: Defines the If-None-Match condition. The operation + will be performed only if the ETag on the server does not match this + value. + :type if_none_match: str + """ + + _attribute_map = { + 'if_none_match': {'key': '', 'type': 'str'}, + } + + def __init__(self, *, if_none_match: str=None, **kwargs) -> None: + super(AccessCondition, self).__init__(**kwargs) + self.if_none_match = if_none_match + + +class AccountOptions(Model): + """Additional parameters for a set of operations. + + All required parameters must be populated in order to send to Azure. + + :param instance_id: Required. Account instance identifier. + :type instance_id: str + """ + + _validation = { + 'instance_id': {'required': True}, + } + + _attribute_map = { + 'instance_id': {'key': '', 'type': 'str'}, + } + + def __init__(self, *, instance_id: str, **kwargs) -> None: + super(AccountOptions, self).__init__(**kwargs) + self.instance_id = instance_id + + +class Compatibility(Model): + """Update compatibility information. + + All required parameters must be populated in order to send to Azure. + + :param device_manufacturer: Required. The manufacturer of device the + update is compatible with. + :type device_manufacturer: str + :param device_model: Required. The model of device the update is + compatible with. + :type device_model: str + """ + + _validation = { + 'device_manufacturer': {'required': True}, + 'device_model': {'required': True}, + } + + _attribute_map = { + 'device_manufacturer': {'key': 'deviceManufacturer', 'type': 'str'}, + 'device_model': {'key': 'deviceModel', 'type': 'str'}, + } + + def __init__(self, *, device_manufacturer: str, device_model: str, **kwargs) -> None: + super(Compatibility, self).__init__(**kwargs) + self.device_manufacturer = device_manufacturer + self.device_model = device_model + + +class Deployment(Model): + """Deployment metadata. + + All required parameters must be populated in order to send to Azure. + + :param deployment_id: Required. Gets or sets the deployment identifier. + :type deployment_id: str + :param deployment_type: Required. Gets or sets the deployment type. + Possible values include: 'Complete', 'Download', 'Install' + :type deployment_type: str or ~azure.deviceupdate.models.DeploymentType + :param device_class_id: Gets or sets the device class identifier. + :type device_class_id: str + :param start_date_time: Required. Gets or sets the Deployment start + datetime. + :type start_date_time: datetime + :param device_group_type: Required. Gets or sets the device group type. + Possible values include: 'All', 'Devices', 'DeviceGroupDefinitions' + :type device_group_type: str or ~azure.deviceupdate.models.DeviceGroupType + :param device_group_definition: Required. Gets or sets the device group + definition. + :type device_group_definition: list[str] + :param update_id: Required. Update identity. + :type update_id: ~azure.deviceupdate.models.UpdateId + :param is_canceled: Boolean flag indicating whether the deployment was + canceled. + :type is_canceled: bool + :param is_retried: Boolean flag indicating whether the deployment has been + retried. + :type is_retried: bool + :param is_completed: Boolean flag indicating whether the deployment was + completed. + :type is_completed: bool + """ + + _validation = { + 'deployment_id': {'required': True}, + 'deployment_type': {'required': True}, + 'start_date_time': {'required': True}, + 'device_group_type': {'required': True}, + 'device_group_definition': {'required': True}, + 'update_id': {'required': True}, + } + + _attribute_map = { + 'deployment_id': {'key': 'deploymentId', 'type': 'str'}, + 'deployment_type': {'key': 'deploymentType', 'type': 'str'}, + 'device_class_id': {'key': 'deviceClassId', 'type': 'str'}, + 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, + 'device_group_type': {'key': 'deviceGroupType', 'type': 'str'}, + 'device_group_definition': {'key': 'deviceGroupDefinition', 'type': '[str]'}, + 'update_id': {'key': 'updateId', 'type': 'UpdateId'}, + 'is_canceled': {'key': 'isCanceled', 'type': 'bool'}, + 'is_retried': {'key': 'isRetried', 'type': 'bool'}, + 'is_completed': {'key': 'isCompleted', 'type': 'bool'}, + } + + def __init__(self, *, deployment_id: str, deployment_type, start_date_time, device_group_type, device_group_definition, update_id, device_class_id: str=None, is_canceled: bool=None, is_retried: bool=None, is_completed: bool=None, **kwargs) -> None: + super(Deployment, self).__init__(**kwargs) + self.deployment_id = deployment_id + self.deployment_type = deployment_type + self.device_class_id = device_class_id + self.start_date_time = start_date_time + self.device_group_type = device_group_type + self.device_group_definition = device_group_definition + self.update_id = update_id + self.is_canceled = is_canceled + self.is_retried = is_retried + self.is_completed = is_completed + + +class DeploymentDeviceState(Model): + """Deployment device status. + + All required parameters must be populated in order to send to Azure. + + :param device_id: Required. Device identity. + :type device_id: str + :param retry_count: Required. The number of times this deployment has been + retried on this device. + :type retry_count: int + :param moved_on_to_new_deployment: Required. Boolean flag indicating + whether this device is in a newer deployment and can no longer retry this + deployment. + :type moved_on_to_new_deployment: bool + :param device_state: Required. Deployment device state. Possible values + include: 'Succeeded', 'InProgress', 'Failed', 'Canceled', 'Incompatible' + :type device_state: str or + ~azure.deviceupdate.models.DeviceDeploymentState + """ + + _validation = { + 'device_id': {'required': True}, + 'retry_count': {'required': True}, + 'moved_on_to_new_deployment': {'required': True}, + 'device_state': {'required': True}, + } + + _attribute_map = { + 'device_id': {'key': 'deviceId', 'type': 'str'}, + 'retry_count': {'key': 'retryCount', 'type': 'int'}, + 'moved_on_to_new_deployment': {'key': 'movedOnToNewDeployment', 'type': 'bool'}, + 'device_state': {'key': 'deviceState', 'type': 'str'}, + } + + def __init__(self, *, device_id: str, retry_count: int, moved_on_to_new_deployment: bool, device_state, **kwargs) -> None: + super(DeploymentDeviceState, self).__init__(**kwargs) + self.device_id = device_id + self.retry_count = retry_count + self.moved_on_to_new_deployment = moved_on_to_new_deployment + self.device_state = device_state + + +class DeploymentDeviceStatesFilter(Model): + """Deployment device state filter. + + :param device_id: Device Identifier. + :type device_id: str + :param device_state: The deployment device state. Possible values include: + 'NotStarted', 'Incompatible', 'AlreadyInDeployment', 'Canceled', + 'InProgress', 'Failed', 'Succeeded' + :type device_state: str or ~azure.deviceupdate.models.DeviceState + """ + + _attribute_map = { + 'device_id': {'key': 'deviceId', 'type': 'str'}, + 'device_state': {'key': 'deviceState', 'type': 'str'}, + } + + def __init__(self, *, device_id: str=None, device_state=None, **kwargs) -> None: + super(DeploymentDeviceStatesFilter, self).__init__(**kwargs) + self.device_id = device_id + self.device_state = device_state + + +class DeploymentFilter(Model): + """Deployment filter. + + :param provider: Update provider. + :type provider: str + :param name: Update name. + :type name: str + :param version: Update version. + :type version: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__(self, *, provider: str=None, name: str=None, version: str=None, **kwargs) -> None: + super(DeploymentFilter, self).__init__(**kwargs) + self.provider = provider + self.name = name + self.version = version + + +class DeploymentStatus(Model): + """Deployment status metadata. + + All required parameters must be populated in order to send to Azure. + + :param deployment_state: Required. Gets or sets the state of the + deployment. Possible values include: 'Active', 'Superseded', 'Canceled' + :type deployment_state: str or ~azure.deviceupdate.models.DeploymentState + :param total_devices: Gets or sets the total number of devices in the + deployment. + :type total_devices: int + :param devices_incompatible_count: Gets or sets the number of incompatible + devices in the deployment. + :type devices_incompatible_count: int + :param devices_in_progress_count: Gets or sets the number of devices that + are currently in deployment. + :type devices_in_progress_count: int + :param devices_completed_failed_count: Gets or sets the number of devices + that have completed deployment with a failure. + :type devices_completed_failed_count: int + :param devices_completed_succeeded_count: Gets or sets the number of + devices which have successfully completed deployment. + :type devices_completed_succeeded_count: int + :param devices_canceled_count: Gets or sets the number of devices which + have had their deployment canceled. + :type devices_canceled_count: int + """ + + _validation = { + 'deployment_state': {'required': True}, + } + + _attribute_map = { + 'deployment_state': {'key': 'deploymentState', 'type': 'str'}, + 'total_devices': {'key': 'totalDevices', 'type': 'int'}, + 'devices_incompatible_count': {'key': 'devicesIncompatibleCount', 'type': 'int'}, + 'devices_in_progress_count': {'key': 'devicesInProgressCount', 'type': 'int'}, + 'devices_completed_failed_count': {'key': 'devicesCompletedFailedCount', 'type': 'int'}, + 'devices_completed_succeeded_count': {'key': 'devicesCompletedSucceededCount', 'type': 'int'}, + 'devices_canceled_count': {'key': 'devicesCanceledCount', 'type': 'int'}, + } + + def __init__(self, *, deployment_state, total_devices: int=None, devices_incompatible_count: int=None, devices_in_progress_count: int=None, devices_completed_failed_count: int=None, devices_completed_succeeded_count: int=None, devices_canceled_count: int=None, **kwargs) -> None: + super(DeploymentStatus, self).__init__(**kwargs) + self.deployment_state = deployment_state + self.total_devices = total_devices + self.devices_incompatible_count = devices_incompatible_count + self.devices_in_progress_count = devices_in_progress_count + self.devices_completed_failed_count = devices_completed_failed_count + self.devices_completed_succeeded_count = devices_completed_succeeded_count + self.devices_canceled_count = devices_canceled_count + + +class Device(Model): + """Device metadata. + + All required parameters must be populated in order to send to Azure. + + :param device_id: Required. Device identity. + :type device_id: str + :param device_class_id: Required. Device class identity. + :type device_class_id: str + :param manufacturer: Required. Device manufacturer. + :type manufacturer: str + :param model: Required. Device model. + :type model: str + :param group_id: Device group identity. + :type group_id: str + :param last_attempted_update_id: Update identity. + :type last_attempted_update_id: ~azure.deviceupdate.models.UpdateId + :param deployment_status: State of the device in its last deployment. + Possible values include: 'Succeeded', 'InProgress', 'Failed', 'Canceled', + 'Incompatible' + :type deployment_status: str or + ~azure.deviceupdate.models.DeviceDeploymentState + :param installed_update_id: Update identity. + :type installed_update_id: ~azure.deviceupdate.models.UpdateId + :param on_latest_update: Required. Boolean flag indicating whether the + latest update is installed on the device + :type on_latest_update: bool + :param last_deployment_id: The deployment identifier for the last + deployment to the device + :type last_deployment_id: str + """ + + _validation = { + 'device_id': {'required': True}, + 'device_class_id': {'required': True}, + 'manufacturer': {'required': True}, + 'model': {'required': True}, + 'on_latest_update': {'required': True}, + } + + _attribute_map = { + 'device_id': {'key': 'deviceId', 'type': 'str'}, + 'device_class_id': {'key': 'deviceClassId', 'type': 'str'}, + 'manufacturer': {'key': 'manufacturer', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'group_id': {'key': 'groupId', 'type': 'str'}, + 'last_attempted_update_id': {'key': 'lastAttemptedUpdateId', 'type': 'UpdateId'}, + 'deployment_status': {'key': 'deploymentStatus', 'type': 'str'}, + 'installed_update_id': {'key': 'installedUpdateId', 'type': 'UpdateId'}, + 'on_latest_update': {'key': 'onLatestUpdate', 'type': 'bool'}, + 'last_deployment_id': {'key': 'lastDeploymentId', 'type': 'str'}, + } + + def __init__(self, *, device_id: str, device_class_id: str, manufacturer: str, model: str, on_latest_update: bool, group_id: str=None, last_attempted_update_id=None, deployment_status=None, installed_update_id=None, last_deployment_id: str=None, **kwargs) -> None: + super(Device, self).__init__(**kwargs) + self.device_id = device_id + self.device_class_id = device_class_id + self.manufacturer = manufacturer + self.model = model + self.group_id = group_id + self.last_attempted_update_id = last_attempted_update_id + self.deployment_status = deployment_status + self.installed_update_id = installed_update_id + self.on_latest_update = on_latest_update + self.last_deployment_id = last_deployment_id + + +class DeviceClass(Model): + """Device class metadata. + + All required parameters must be populated in order to send to Azure. + + :param device_class_id: Required. The device class identifier. + :type device_class_id: str + :param manufacturer: Required. Device manufacturer + :type manufacturer: str + :param model: Required. Device model. + :type model: str + :param best_compatible_update_id: Required. Update identity. + :type best_compatible_update_id: ~azure.deviceupdate.models.UpdateId + """ + + _validation = { + 'device_class_id': {'required': True}, + 'manufacturer': {'required': True}, + 'model': {'required': True}, + 'best_compatible_update_id': {'required': True}, + } + + _attribute_map = { + 'device_class_id': {'key': 'deviceClassId', 'type': 'str'}, + 'manufacturer': {'key': 'manufacturer', 'type': 'str'}, + 'model': {'key': 'model', 'type': 'str'}, + 'best_compatible_update_id': {'key': 'bestCompatibleUpdateId', 'type': 'UpdateId'}, + } + + def __init__(self, *, device_class_id: str, manufacturer: str, model: str, best_compatible_update_id, **kwargs) -> None: + super(DeviceClass, self).__init__(**kwargs) + self.device_class_id = device_class_id + self.manufacturer = manufacturer + self.model = model + self.best_compatible_update_id = best_compatible_update_id + + +class DeviceFilter(Model): + """Operation status filter. + + :param group_id: Device group identifier. + :type group_id: str + """ + + _attribute_map = { + 'group_id': {'key': 'groupId', 'type': 'str'}, + } + + def __init__(self, *, group_id: str=None, **kwargs) -> None: + super(DeviceFilter, self).__init__(**kwargs) + self.group_id = group_id + + +class DeviceTag(Model): + """Device tag properties. + + All required parameters must be populated in order to send to Azure. + + :param tag_name: Required. Tag name. + :type tag_name: str + :param device_count: Required. Number of devices with this tag. + :type device_count: int + """ + + _validation = { + 'tag_name': {'required': True}, + 'device_count': {'required': True}, + } + + _attribute_map = { + 'tag_name': {'key': 'tagName', 'type': 'str'}, + 'device_count': {'key': 'deviceCount', 'type': 'int'}, + } + + def __init__(self, *, tag_name: str, device_count: int, **kwargs) -> None: + super(DeviceTag, self).__init__(**kwargs) + self.tag_name = tag_name + self.device_count = device_count + + +class Error(Model): + """Error details. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. Server defined error code. + :type code: str + :param message: Required. A human-readable representation of the error. + :type message: str + :param target: The target of the error. + :type target: str + :param details: An array of errors that led to the reported error. + :type details: list[~azure.deviceupdate.models.Error] + :param innererror: An object containing more specific information than the + current object about the error. + :type innererror: ~azure.deviceupdate.models.InnerError + :param occurred_date_time: Date and time in UTC when the error occurred. + :type occurred_date_time: datetime + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[Error]'}, + 'innererror': {'key': 'innererror', 'type': 'InnerError'}, + 'occurred_date_time': {'key': 'occurredDateTime', 'type': 'iso-8601'}, + } + + def __init__(self, *, code: str, message: str, target: str=None, details=None, innererror=None, occurred_date_time=None, **kwargs) -> None: + super(Error, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + self.innererror = innererror + self.occurred_date_time = occurred_date_time + + +class File(Model): + """Update file metadata. + + All required parameters must be populated in order to send to Azure. + + :param file_id: Required. File identity, generated by server at import + time. + :type file_id: str + :param file_name: Required. File name. + :type file_name: str + :param size_in_bytes: Required. File size in number of bytes. + :type size_in_bytes: long + :param hashes: Required. Mapping of hashing algorithm to base64 encoded + hash values. + :type hashes: dict[str, str] + :param mime_type: File MIME type. + :type mime_type: str + :param etag: File ETag. + :type etag: str + """ + + _validation = { + 'file_id': {'required': True}, + 'file_name': {'required': True}, + 'size_in_bytes': {'required': True}, + 'hashes': {'required': True}, + } + + _attribute_map = { + 'file_id': {'key': 'fileId', 'type': 'str'}, + 'file_name': {'key': 'fileName', 'type': 'str'}, + 'size_in_bytes': {'key': 'sizeInBytes', 'type': 'long'}, + 'hashes': {'key': 'hashes', 'type': '{str}'}, + 'mime_type': {'key': 'mimeType', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__(self, *, file_id: str, file_name: str, size_in_bytes: int, hashes, mime_type: str=None, etag: str=None, **kwargs) -> None: + super(File, self).__init__(**kwargs) + self.file_id = file_id + self.file_name = file_name + self.size_in_bytes = size_in_bytes + self.hashes = hashes + self.mime_type = mime_type + self.etag = etag + + +class FileImportMetadata(Model): + """Metadata describing an update file. + + All required parameters must be populated in order to send to Azure. + + :param filename: Required. Update file name as specified inside import + manifest. + :type filename: str + :param url: Required. Azure Blob location from which the update file can + be downloaded by Device Update for IoT Hub. This is typically a read-only + SAS-protected blob URL with an expiration set to at least 4 hours. + :type url: str + """ + + _validation = { + 'filename': {'required': True}, + 'url': {'required': True}, + } + + _attribute_map = { + 'filename': {'key': 'filename', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + } + + def __init__(self, *, filename: str, url: str, **kwargs) -> None: + super(FileImportMetadata, self).__init__(**kwargs) + self.filename = filename + self.url = url + + +class Group(Model): + """Group details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param group_id: Required. Group identity. + :type group_id: str + :ivar group_type: Required. Group type. Default value: "IoTHubTag" . + :vartype group_type: str + :param tags: Required. IoT Hub tags. + :type tags: list[str] + :param created_date_time: Required. Date and time when the update was + created. + :type created_date_time: str + :param device_count: The number of devices in the group. + :type device_count: int + """ + + _validation = { + 'group_id': {'required': True}, + 'group_type': {'required': True, 'constant': True}, + 'tags': {'required': True}, + 'created_date_time': {'required': True}, + } + + _attribute_map = { + 'group_id': {'key': 'groupId', 'type': 'str'}, + 'group_type': {'key': 'groupType', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '[str]'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'str'}, + 'device_count': {'key': 'deviceCount', 'type': 'int'}, + } + + group_type = "IoTHubTag" + + def __init__(self, *, group_id: str, tags, created_date_time: str, device_count: int=None, **kwargs) -> None: + super(Group, self).__init__(**kwargs) + self.group_id = group_id + self.tags = tags + self.created_date_time = created_date_time + self.device_count = device_count + + +class GroupBestUpdatesFilter(Model): + """Group best updates filter. + + :param provider: Update provider. + :type provider: str + :param name: Update name. + :type name: str + :param version: Update version. + :type version: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__(self, *, provider: str=None, name: str=None, version: str=None, **kwargs) -> None: + super(GroupBestUpdatesFilter, self).__init__(**kwargs) + self.provider = provider + self.name = name + self.version = version + + +class ImportManifestMetadata(Model): + """Metadata describing the import manifest, a document which describes the + files and other metadata about an update version. + + All required parameters must be populated in order to send to Azure. + + :param url: Required. Azure Blob location from which the import manifest + can be downloaded by Device Update for IoT Hub. This is typically a + read-only SAS-protected blob URL with an expiration set to at least 4 + hours. + :type url: str + :param size_in_bytes: Required. File size in number of bytes. + :type size_in_bytes: long + :param hashes: Required. A JSON object containing the hash(es) of the + file. At least SHA256 hash is required. This object can be thought of as a + set of key-value pairs where the key is the hash algorithm, and the value + is the hash of the file calculated using that algorithm. + :type hashes: dict[str, str] + """ + + _validation = { + 'url': {'required': True}, + 'size_in_bytes': {'required': True}, + 'hashes': {'required': True}, + } + + _attribute_map = { + 'url': {'key': 'url', 'type': 'str'}, + 'size_in_bytes': {'key': 'sizeInBytes', 'type': 'long'}, + 'hashes': {'key': 'hashes', 'type': '{str}'}, + } + + def __init__(self, *, url: str, size_in_bytes: int, hashes, **kwargs) -> None: + super(ImportManifestMetadata, self).__init__(**kwargs) + self.url = url + self.size_in_bytes = size_in_bytes + self.hashes = hashes + + +class ImportUpdateInput(Model): + """Import update input metadata. + + All required parameters must be populated in order to send to Azure. + + :param import_manifest: Required. Import manifest metadata like source + URL, file size/hashes, etc. + :type import_manifest: ~azure.deviceupdate.models.ImportManifestMetadata + :param files: Required. One or more update file properties like filename + and source URL. + :type files: list[~azure.deviceupdate.models.FileImportMetadata] + """ + + _validation = { + 'import_manifest': {'required': True}, + 'files': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'import_manifest': {'key': 'importManifest', 'type': 'ImportManifestMetadata'}, + 'files': {'key': 'files', 'type': '[FileImportMetadata]'}, + } + + def __init__(self, *, import_manifest, files, **kwargs) -> None: + super(ImportUpdateInput, self).__init__(**kwargs) + self.import_manifest = import_manifest + self.files = files + + +class InnerError(Model): + """An object containing more specific information than the current object + about the error. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. A more specific error code than what was provided + by the containing error. + :type code: str + :param message: A human-readable representation of the error. + :type message: str + :param error_detail: The internal error or exception message. + :type error_detail: str + :param inner_error: An object containing more specific information than + the current object about the error. + :type inner_error: ~azure.deviceupdate.models.InnerError + """ + + _validation = { + 'code': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'error_detail': {'key': 'errorDetail', 'type': 'str'}, + 'inner_error': {'key': 'innerError', 'type': 'InnerError'}, + } + + def __init__(self, *, code: str, message: str=None, error_detail: str=None, inner_error=None, **kwargs) -> None: + super(InnerError, self).__init__(**kwargs) + self.code = code + self.message = message + self.error_detail = error_detail + self.inner_error = inner_error + + +class Operation(Model): + """Operation metadata. + + All required parameters must be populated in order to send to Azure. + + :param operation_id: Required. Operation Id. + :type operation_id: str + :param status: Required. Operation status. Possible values include: + 'Undefined', 'NotStarted', 'Running', 'Succeeded', 'Failed' + :type status: str or ~azure.deviceupdate.models.OperationStatus + :param update_id: The identity of update being imported or deleted. For + import, this property will only be populated after import manifest is + processed successfully. + :type update_id: ~azure.deviceupdate.models.UpdateId + :param resource_location: Location of the imported update when operation + is successful. + :type resource_location: str + :param error: Operation error encountered, if any. + :type error: ~azure.deviceupdate.models.Error + :param trace_id: Operation correlation identity that can used by Microsoft + Support for troubleshooting. + :type trace_id: str + :param last_action_date_time: Required. Date and time in UTC when the + operation status was last updated. + :type last_action_date_time: datetime + :param created_date_time: Required. Date and time in UTC when the + operation was created. + :type created_date_time: datetime + :param etag: Operation ETag. + :type etag: str + """ + + _validation = { + 'operation_id': {'required': True}, + 'status': {'required': True}, + 'last_action_date_time': {'required': True}, + 'created_date_time': {'required': True}, + } + + _attribute_map = { + 'operation_id': {'key': 'operationId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'update_id': {'key': 'updateId', 'type': 'UpdateId'}, + 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'Error'}, + 'trace_id': {'key': 'traceId', 'type': 'str'}, + 'last_action_date_time': {'key': 'lastActionDateTime', 'type': 'iso-8601'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__(self, *, operation_id: str, status, last_action_date_time, created_date_time, update_id=None, resource_location: str=None, error=None, trace_id: str=None, etag: str=None, **kwargs) -> None: + super(Operation, self).__init__(**kwargs) + self.operation_id = operation_id + self.status = status + self.update_id = update_id + self.resource_location = resource_location + self.error = error + self.trace_id = trace_id + self.last_action_date_time = last_action_date_time + self.created_date_time = created_date_time + self.etag = etag + + +class OperationFilter(Model): + """Operation status filter. + + :param status: Operation status filter. Possible values include: + 'Running', 'NotStarted' + :type status: str or ~azure.deviceupdate.models.OperationFilterStatus + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__(self, *, status=None, **kwargs) -> None: + super(OperationFilter, self).__init__(**kwargs) + self.status = status + + +class PageableListOfDeploymentDeviceStates(Model): + """The list of deployment device states. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.DeploymentDeviceState] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentDeviceState]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfDeploymentDeviceStates, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PageableListOfDeployments(Model): + """The list of deployments. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.Deployment] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Deployment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfDeployments, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PageableListOfDeviceClasses(Model): + """The list of device classes. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.DeviceClass] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeviceClass]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfDeviceClasses, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PageableListOfDevices(Model): + """The list of devices. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.Device] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Device]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfDevices, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PageableListOfDeviceTags(Model): + """The list of device tags. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.DeviceTag] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeviceTag]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfDeviceTags, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PageableListOfGroups(Model): + """The list of groups. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.Group] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Group]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfGroups, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PageableListOfOperations(Model): + """The list of operations with server paging support. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.Operation] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfOperations, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PageableListOfStrings(Model): + """The list of strings with server paging support. + + :param value: The collection of pageable items. + :type value: list[str] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[str]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfStrings, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PageableListOfUpdatableDevices(Model): + """The list of updatable devices. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.UpdatableDevices] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UpdatableDevices]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfUpdatableDevices, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PageableListOfUpdateIds(Model): + """The list of update identities. + + :param value: The collection of pageable items. + :type value: list[~azure.deviceupdate.models.UpdateId] + :param next_link: The link to the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UpdateId]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + super(PageableListOfUpdateIds, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class UpdatableDevices(Model): + """Update identifier and the number of devices for which the update is + applicable. + + All required parameters must be populated in order to send to Azure. + + :param update_id: Required. Update identity. + :type update_id: ~azure.deviceupdate.models.UpdateId + :param device_count: Required. Total number of devices for which the + update is applicable. + :type device_count: int + """ + + _validation = { + 'update_id': {'required': True}, + 'device_count': {'required': True}, + } + + _attribute_map = { + 'update_id': {'key': 'updateId', 'type': 'UpdateId'}, + 'device_count': {'key': 'deviceCount', 'type': 'int'}, + } + + def __init__(self, *, update_id, device_count: int, **kwargs) -> None: + super(UpdatableDevices, self).__init__(**kwargs) + self.update_id = update_id + self.device_count = device_count + + +class Update(Model): + """Update metadata. + + All required parameters must be populated in order to send to Azure. + + :param update_id: Required. Update identity. + :type update_id: ~azure.deviceupdate.models.UpdateId + :param update_type: Required. Update type. + :type update_type: str + :param installed_criteria: Required. String interpreted by Device Update + client to determine if the update is installed on the device. + :type installed_criteria: str + :param compatibility: Required. List of update compatibility information. + :type compatibility: list[~azure.deviceupdate.models.Compatibility] + :param manifest_version: Required. Schema version of manifest used to + import the update. + :type manifest_version: str + :param imported_date_time: Required. Date and time in UTC when the update + was imported. + :type imported_date_time: datetime + :param created_date_time: Required. Date and time in UTC when the update + was created. + :type created_date_time: datetime + :param etag: Update ETag. + :type etag: str + """ + + _validation = { + 'update_id': {'required': True}, + 'update_type': {'required': True}, + 'installed_criteria': {'required': True}, + 'compatibility': {'required': True, 'min_items': 1}, + 'manifest_version': {'required': True}, + 'imported_date_time': {'required': True}, + 'created_date_time': {'required': True}, + } + + _attribute_map = { + 'update_id': {'key': 'updateId', 'type': 'UpdateId'}, + 'update_type': {'key': 'updateType', 'type': 'str'}, + 'installed_criteria': {'key': 'installedCriteria', 'type': 'str'}, + 'compatibility': {'key': 'compatibility', 'type': '[Compatibility]'}, + 'manifest_version': {'key': 'manifestVersion', 'type': 'str'}, + 'imported_date_time': {'key': 'importedDateTime', 'type': 'iso-8601'}, + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__(self, *, update_id, update_type: str, installed_criteria: str, compatibility, manifest_version: str, imported_date_time, created_date_time, etag: str=None, **kwargs) -> None: + super(Update, self).__init__(**kwargs) + self.update_id = update_id + self.update_type = update_type + self.installed_criteria = installed_criteria + self.compatibility = compatibility + self.manifest_version = manifest_version + self.imported_date_time = imported_date_time + self.created_date_time = created_date_time + self.etag = etag + + +class UpdateCompliance(Model): + """Update compliance information. + + All required parameters must be populated in order to send to Azure. + + :param total_device_count: Required. Total number of devices. + :type total_device_count: int + :param on_latest_update_device_count: Required. Number of devices on the + latest update. + :type on_latest_update_device_count: int + :param new_updates_available_device_count: Required. Number of devices + with a newer update available. + :type new_updates_available_device_count: int + :param updates_in_progress_device_count: Required. Number of devices with + update in-progress. + :type updates_in_progress_device_count: int + """ + + _validation = { + 'total_device_count': {'required': True}, + 'on_latest_update_device_count': {'required': True}, + 'new_updates_available_device_count': {'required': True}, + 'updates_in_progress_device_count': {'required': True}, + } + + _attribute_map = { + 'total_device_count': {'key': 'totalDeviceCount', 'type': 'int'}, + 'on_latest_update_device_count': {'key': 'onLatestUpdateDeviceCount', 'type': 'int'}, + 'new_updates_available_device_count': {'key': 'newUpdatesAvailableDeviceCount', 'type': 'int'}, + 'updates_in_progress_device_count': {'key': 'updatesInProgressDeviceCount', 'type': 'int'}, + } + + def __init__(self, *, total_device_count: int, on_latest_update_device_count: int, new_updates_available_device_count: int, updates_in_progress_device_count: int, **kwargs) -> None: + super(UpdateCompliance, self).__init__(**kwargs) + self.total_device_count = total_device_count + self.on_latest_update_device_count = on_latest_update_device_count + self.new_updates_available_device_count = new_updates_available_device_count + self.updates_in_progress_device_count = updates_in_progress_device_count + + +class UpdateId(Model): + """Update identifier. + + All required parameters must be populated in order to send to Azure. + + :param provider: Required. Update provider. + :type provider: str + :param name: Required. Update name. + :type name: str + :param version: Required. Update version. + :type version: str + """ + + _validation = { + 'provider': {'required': True}, + 'name': {'required': True}, + 'version': {'required': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + } + + def __init__(self, *, provider: str, name: str, version: str, **kwargs) -> None: + super(UpdateId, self).__init__(**kwargs) + self.provider = provider + self.name = name + self.version = version diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/__init__.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/__init__.py new file mode 100644 index 000000000000..63c42c41155a --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from ._updates_operations import UpdatesOperations +from ._devices_operations import DevicesOperations +from ._deployments_operations import DeploymentsOperations + +__all__ = [ + 'UpdatesOperations', + 'DevicesOperations', + 'DeploymentsOperations', +] diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/_deployments_operations.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/_deployments_operations.py new file mode 100644 index 000000000000..cdd5fc66c447 --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/_deployments_operations.py @@ -0,0 +1,520 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse +from msrest.exceptions import HttpOperationError + +from .. import models + + +class DeploymentsOperations(object): + """DeploymentsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def get_all_deployments( + self, account_options, filter=None, custom_headers=None, raw=False, **operation_config): + """Gets a list of deployments. + + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param filter: Restricts the set of deployments returned. You can + filter on update Provider, Name and Version property. + :type filter: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfDeployments or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfDeployments or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_all_deployments.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfDeployments', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_all_deployments.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deployments'} + + def get_deployment( + self, deployment_id, account_options, custom_headers=None, raw=False, **operation_config): + """Gets the properties of a deployment. + + :param deployment_id: Deployment identifier. + :type deployment_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Deployment or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.Deployment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_deployment.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Deployment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_deployment.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deployments/{deploymentId}'} + + def create_or_update_deployment( + self, deployment_id, deployment, account_options, custom_headers=None, raw=False, **operation_config): + """Creates or updates a deployment. + + :param deployment_id: Deployment identifier. + :type deployment_id: str + :param deployment: The deployment properties. + :type deployment: ~azure.deviceupdate.models.Deployment + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Deployment or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.Deployment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.create_or_update_deployment.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(deployment, 'Deployment') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Deployment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update_deployment.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deployments/{deploymentId}'} + + def delete_deployment( + self, deployment_id, account_options, custom_headers=None, raw=False, **operation_config): + """Deletes a deployment. + + :param deployment_id: Deployment identifier. + :type deployment_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.delete_deployment.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_deployment.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deployments/{deploymentId}'} + + def get_deployment_status( + self, deployment_id, account_options, custom_headers=None, raw=False, **operation_config): + """Gets the status of a deployment including a breakdown of how many + devices in the deployment are in progress, completed, or failed. + + :param deployment_id: Deployment identifier. + :type deployment_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: DeploymentStatus or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.DeploymentStatus or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_deployment_status.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentStatus', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_deployment_status.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deployments/{deploymentId}/status'} + + def get_deployment_devices( + self, deployment_id, account_options, filter=None, custom_headers=None, raw=False, **operation_config): + """Gets a list of devices in a deployment along with their state. Useful + for getting a list of failed devices. + + :param deployment_id: Deployment identifier. + :type deployment_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param filter: Restricts the set of deployment device states returned. + You can filter on deviceId and/or deviceState. + :type filter: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfDeploymentDeviceStates or ClientRawResponse if + raw=true + :rtype: + ~azure.deviceupdate.models.PageableListOfDeploymentDeviceStates or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_deployment_devices.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfDeploymentDeviceStates', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_deployment_devices.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deployments/{deploymentId}/devicestates'} + + def cancel_deployment( + self, deployment_id, account_options, custom_headers=None, raw=False, **operation_config): + """Cancels a deployment. + + :param deployment_id: Deployment identifier. + :type deployment_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Deployment or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.Deployment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + action = "cancel" + + # Construct URL + url = self.cancel_deployment.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['action'] = self._serialize.query("action", action, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Deployment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + cancel_deployment.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deployments/{deploymentId}'} + + def retry_deployment( + self, deployment_id, account_options, custom_headers=None, raw=False, **operation_config): + """Retries a deployment with failed devices. + + :param deployment_id: Deployment identifier. + :type deployment_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Deployment or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.Deployment or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + action = "retry" + + # Construct URL + url = self.retry_deployment.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['action'] = self._serialize.query("action", action, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Deployment', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + retry_deployment.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deployments/{deploymentId}'} diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/_devices_operations.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/_devices_operations.py new file mode 100644 index 000000000000..4b1a191234ea --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/_devices_operations.py @@ -0,0 +1,920 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse +from msrest.exceptions import HttpOperationError + +from .. import models + + +class DevicesOperations(object): + """DevicesOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def get_all_device_classes( + self, account_options, custom_headers=None, raw=False, **operation_config): + """Gets a list of all device classes (unique combinations of device + manufacturer and model) for all devices connected to Device Update for + IoT Hub. + + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfDeviceClasses or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfDeviceClasses or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_all_device_classes.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfDeviceClasses', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_all_device_classes.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deviceclasses'} + + def get_device_class( + self, device_class_id, account_options, custom_headers=None, raw=False, **operation_config): + """Gets the properties of a device class. + + :param device_class_id: Device class identifier. + :type device_class_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: DeviceClass or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.DeviceClass or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_device_class.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deviceClassId': self._serialize.url("device_class_id", device_class_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeviceClass', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_device_class.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deviceclasses/{deviceClassId}'} + + def get_device_class_device_ids( + self, device_class_id, account_options, custom_headers=None, raw=False, **operation_config): + """Gets a list of device identifiers in a device class. + + :param device_class_id: Device class identifier. + :type device_class_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfStrings or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfStrings or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_device_class_device_ids.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deviceClassId': self._serialize.url("device_class_id", device_class_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfStrings', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_device_class_device_ids.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deviceclasses/{deviceClassId}/deviceids'} + + def get_device_class_installable_updates( + self, device_class_id, account_options, custom_headers=None, raw=False, **operation_config): + """Gets a list of installable updates for a device class. + + :param device_class_id: Device class identifier. + :type device_class_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfUpdateIds or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfUpdateIds or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_device_class_installable_updates.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deviceClassId': self._serialize.url("device_class_id", device_class_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfUpdateIds', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_device_class_installable_updates.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deviceclasses/{deviceClassId}/installableupdates'} + + def get_all_devices( + self, account_options, filter=None, custom_headers=None, raw=False, **operation_config): + """Gets a list of devices connected to Device Update for IoT Hub. + + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param filter: Restricts the set of devices returned. You can only + filter on device GroupId. + :type filter: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfDevices or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfDevices or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_all_devices.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfDevices', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_all_devices.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/devices'} + + def get_device( + self, device_id, account_options, custom_headers=None, raw=False, **operation_config): + """Gets the device properties and latest deployment status for a device + connected to Device Update for IoT Hub. + + :param device_id: Device identifier in Azure IOT Hub. + :type device_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Device or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.Device or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_device.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'deviceId': self._serialize.url("device_id", device_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Device', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_device.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/devices/{deviceId}'} + + def get_update_compliance( + self, account_options, custom_headers=None, raw=False, **operation_config): + """Gets the breakdown of how many devices are on their latest update, have + new updates available, or are in progress receiving new updates. + + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: UpdateCompliance or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.UpdateCompliance or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_update_compliance.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('UpdateCompliance', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_update_compliance.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/updatecompliance'} + + def get_all_device_tags( + self, account_options, custom_headers=None, raw=False, **operation_config): + """Gets a list of available group device tags for all devices connected to + Device Update for IoT Hub. + + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfDeviceTags or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfDeviceTags or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_all_device_tags.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfDeviceTags', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_all_device_tags.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/devicetags'} + + def get_device_tag( + self, tag_name, account_options, custom_headers=None, raw=False, **operation_config): + """Gets a count of how many devices have a device tag. + + :param tag_name: Tag name. + :type tag_name: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: DeviceTag or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.DeviceTag or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_device_tag.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'tagName': self._serialize.url("tag_name", tag_name, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeviceTag', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_device_tag.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/devicetags/{tagName}'} + + def get_all_groups( + self, account_options, custom_headers=None, raw=False, **operation_config): + """Gets a list of all device groups. + + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfGroups or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfGroups or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_all_groups.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfGroups', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_all_groups.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups'} + + def get_group( + self, group_id, account_options, custom_headers=None, raw=False, **operation_config): + """Gets the properties of a group. + + :param group_id: Group identifier. + :type group_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Group or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.Group or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_group.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'groupId': self._serialize.url("group_id", group_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Group', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_group.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}'} + + def create_or_update_group( + self, group_id, group, account_options, custom_headers=None, raw=False, **operation_config): + """Create or update a device group. + + :param group_id: Group identifier. + :type group_id: str + :param group: The group properties. + :type group: ~azure.deviceupdate.models.Group + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Group or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.Group or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.create_or_update_group.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'groupId': self._serialize.url("group_id", group_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(group, 'Group') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 400, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Group', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update_group.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}'} + + def delete_group( + self, group_id, account_options, custom_headers=None, raw=False, **operation_config): + """Deletes a device group. + + :param group_id: Group identifier. + :type group_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.delete_group.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'groupId': self._serialize.url("group_id", group_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + raise HttpOperationError(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_group.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}'} + + def get_group_update_compliance( + self, group_id, account_options, custom_headers=None, raw=False, **operation_config): + """Get group update compliance information such as how many devices are on + their latest update, how many need new updates, and how many are in + progress on receiving a new update. + + :param group_id: Group identifier. + :type group_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: UpdateCompliance or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.UpdateCompliance or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_group_update_compliance.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'groupId': self._serialize.url("group_id", group_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('UpdateCompliance', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_group_update_compliance.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}/updateCompliance'} + + def get_group_best_updates( + self, group_id, account_options, filter=None, custom_headers=None, raw=False, **operation_config): + """Get the best available updates for a group and a count of how many + devices need each update. + + :param group_id: Group identifier. + :type group_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param filter: Restricts the set of bestUpdates returned. You can + filter on update Provider, Name and Version property. + :type filter: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfUpdatableDevices or ClientRawResponse if + raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfUpdatableDevices or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_group_best_updates.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'groupId': self._serialize.url("group_id", group_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfUpdatableDevices', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_group_best_updates.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}/bestUpdates'} diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/_updates_operations.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/_updates_operations.py new file mode 100644 index 000000000000..e16c46744548 --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/operations/_updates_operations.py @@ -0,0 +1,687 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse +from msrest.exceptions import HttpOperationError + +from .. import models + + +class UpdatesOperations(object): + """UpdatesOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar action: Import update action. Constant value: "import". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + self.action = "import" + + def import_update( + self, update_to_import, account_options, custom_headers=None, raw=False, **operation_config): + """Import new update version. + + :param update_to_import: The update to be imported. + :type update_to_import: ~azure.deviceupdate.models.ImportUpdateInput + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.import_update.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['action'] = self._serialize.query("self.action", self.action, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(update_to_import, 'ImportUpdateInput') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [202, 429]: + raise HttpOperationError(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'Location': 'str', + 'Operation-Location': 'str', + }) + return client_raw_response + import_update.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates'} + + def get_update( + self, provider, name, version, account_options, access_condition=None, custom_headers=None, raw=False, **operation_config): + """Get a specific update version. + + :param provider: Update provider. + :type provider: str + :param name: Update name. + :type name: str + :param version: Update version. + :type version: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param access_condition: Additional parameters for the operation + :type access_condition: ~azure.deviceupdate.models.AccessCondition + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Update or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.Update or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + if_none_match = None + if access_condition is not None: + if_none_match = access_condition.if_none_match + + # Construct URL + url = self.get_update.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'provider': self._serialize.url("provider", provider, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'version': self._serialize.url("version", version, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 304, 404, 429]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Update', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_update.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates/providers/{provider}/names/{name}/versions/{version}'} + + def delete_update( + self, provider, name, version, account_options, custom_headers=None, raw=False, **operation_config): + """Delete a specific update version. + + :param provider: Update provider. + :type provider: str + :param name: Update name. + :type name: str + :param version: Update version. + :type version: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.delete_update.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'provider': self._serialize.url("provider", provider, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'version': self._serialize.url("version", version, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [202, 429]: + raise HttpOperationError(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'Location': 'str', + 'Operation-Location': 'str', + }) + return client_raw_response + delete_update.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates/providers/{provider}/names/{name}/versions/{version}'} + + def get_providers( + self, account_options, custom_headers=None, raw=False, **operation_config): + """Get a list of all update providers that have been imported to Device + Update for IoT Hub. + + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfStrings or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfStrings or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_providers.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 429]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfStrings', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_providers.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates/providers'} + + def get_names( + self, provider, account_options, custom_headers=None, raw=False, **operation_config): + """Get a list of all update names that match the specified provider. + + :param provider: Update provider. + :type provider: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfStrings or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfStrings or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_names.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'provider': self._serialize.url("provider", provider, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404, 429]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfStrings', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_names.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates/providers/{provider}/names'} + + def get_versions( + self, provider, name, account_options, custom_headers=None, raw=False, **operation_config): + """Get a list of all update versions that match the specified provider and + name. + + :param provider: Update provider. + :type provider: str + :param name: Update name. + :type name: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfStrings or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfStrings or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_versions.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'provider': self._serialize.url("provider", provider, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404, 429]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfStrings', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_versions.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates/providers/{provider}/names/{name}/versions'} + + def get_files( + self, provider, name, version, account_options, custom_headers=None, raw=False, **operation_config): + """Get a list of all update file identifiers for the specified version. + + :param provider: Update provider. + :type provider: str + :param name: Update name. + :type name: str + :param version: Update version. + :type version: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfStrings or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfStrings or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_files.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'provider': self._serialize.url("provider", provider, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'version': self._serialize.url("version", version, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 404, 429]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfStrings', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_files.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates/providers/{provider}/names/{name}/versions/{version}/files'} + + def get_file( + self, provider, name, version, file_id, account_options, access_condition=None, custom_headers=None, raw=False, **operation_config): + """Get a specific update file from the version. + + :param provider: Update provider. + :type provider: str + :param name: Update name. + :type name: str + :param version: Update version. + :type version: str + :param file_id: File identifier. + :type file_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param access_condition: Additional parameters for the operation + :type access_condition: ~azure.deviceupdate.models.AccessCondition + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: File or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.File or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + if_none_match = None + if access_condition is not None: + if_none_match = access_condition.if_none_match + + # Construct URL + url = self.get_file.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'provider': self._serialize.url("provider", provider, 'str'), + 'name': self._serialize.url("name", name, 'str'), + 'version': self._serialize.url("version", version, 'str'), + 'fileId': self._serialize.url("file_id", file_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 304, 404, 429]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('File', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_file.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}'} + + def get_operations( + self, account_options, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + """Get a list of all import update operations. Completed operations are + kept for 7 days before auto-deleted. Delete operations are not returned + by this API version. + + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param filter: Restricts the set of operations returned. Only one + specific filter is supported: "status eq 'NotStarted' or status eq + 'Running'" + :type filter: str + :param top: Specifies a non-negative integer n that limits the number + of items returned from a collection. The service returns the number of + available items up to but not greater than the specified value n. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PageableListOfOperations or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.PageableListOfOperations or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + + # Construct URL + url = self.get_operations.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 429]: + raise HttpOperationError(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PageableListOfOperations', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_operations.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates/operations'} + + def get_operation( + self, operation_id, account_options, access_condition=None, custom_headers=None, raw=False, **operation_config): + """Retrieve operation status. + + :param operation_id: Operation identifier. + :type operation_id: str + :param account_options: Additional parameters for the operation + :type account_options: ~azure.deviceupdate.models.AccountOptions + :param access_condition: Additional parameters for the operation + :type access_condition: ~azure.deviceupdate.models.AccessCondition + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Operation or ClientRawResponse if raw=true + :rtype: ~azure.deviceupdate.models.Operation or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + self.config.selfconfiginstance_id = None + if account_options is not None: + self.config.selfconfiginstance_id = account_options.instance_id + if_none_match = None + if access_condition is not None: + if_none_match = access_condition.if_none_match + + # Construct URL + url = self.get_operation.metadata['url'] + path_format_arguments = { + 'accountEndpoint': self._serialize.url("self.config.account_endpoint", self.config.account_endpoint, 'str', skip_quote=True), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + 'instanceId': self._serialize.url("self.config.selfconfiginstance_id", self.config.selfconfiginstance_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 304, 404, 429]: + raise HttpOperationError(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Operation', response) + header_dict = { + 'Retry-After': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + get_operation.metadata = {'url': '/deviceupdate/{instanceId}/v2/updates/operations/{operationId}'} diff --git a/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/version.py b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/version.py new file mode 100644 index 000000000000..785473a39563 --- /dev/null +++ b/sdk/sdk/deviceupdate/azure-deviceupdate/azure/deviceupdate/version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# +# -------------------------------------------------------------------------- + +VERSION = "2020-09-01-preview" +