Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release of Device Update for IoT Hub SDK for Python. #17005

Merged
merged 27 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
79e44ff
Release of Device Update for IoT Hub SDK for Python.
Mar 2, 2021
25d66c9
Updating the generated code, sample, tests and recorded sessions.
Mar 2, 2021
a6a2aea
update links, manifest, and allow pylint failures
iscai-msft Mar 2, 2021
8e41822
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
Mar 2, 2021
4da7534
Updated readme links.
Mar 2, 2021
32002e2
fix dev_requirements
iscai-msft Mar 2, 2021
f7ff895
Merge branch 'device-update' of https://github.com/dpokluda/azure-sdk…
iscai-msft Mar 2, 2021
e3ffa53
remove en-us from link in readme
iscai-msft Mar 2, 2021
6f8fc1a
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft Mar 2, 2021
1024efd
switch to powershell preparer, all passing in playback except one
iscai-msft Mar 3, 2021
246afaa
remove tests. and test_data
iscai-msft Mar 3, 2021
7b8ee32
add Azure to top of readme
iscai-msft Mar 3, 2021
b07ca58
change device update core requirement in shared_requirements.txt
iscai-msft Mar 3, 2021
aff03ef
mark scrubbing failure test with live only
iscai-msft Mar 3, 2021
5c62fdd
update date in changelog
iscai-msft Mar 3, 2021
7056987
make changes to readme links and setup.py
iscai-msft Mar 3, 2021
68987bc
switch credential scopes and re-reocrd tests
iscai-msft Mar 3, 2021
eb19425
mark test as live only
iscai-msft Mar 3, 2021
d062d09
remove timezone from tests
iscai-msft Mar 3, 2021
6312c0b
remove mention of 3.5 in readme
iscai-msft Mar 3, 2021
bafea96
Update sample.py
dpokluda Mar 3, 2021
6af10f9
Merge branch 'device-update' of https://github.com/dpokluda/azure-sdk…
dpokluda Mar 3, 2021
5cbd40f
add azure-iot-nspkg to shared_requirements
iscai-msft Mar 3, 2021
91faabd
Merge branch 'device-update' of https://github.com/dpokluda/azure-sdk…
iscai-msft Mar 3, 2021
ab653a0
Update CHANGELOG.md
dpokluda Mar 3, 2021
62f2894
Tweaking sample argument parsing.
dpokluda Mar 3, 2021
7457de0
Updated samples output
dpokluda Mar 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/deviceupdate/azure-iot-deviceupdate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Release History

## 1.0.0b1 (2021-03-03)
- Initial Release
5 changes: 5 additions & 0 deletions sdk/deviceupdate/azure-iot-deviceupdate/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
recursive-include tests *.py
recursive-include samples *.py *.md
include *.md
include azure/__init__.py
include azure/iot/__init__.py
51 changes: 51 additions & 0 deletions sdk/deviceupdate/azure-iot-deviceupdate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Azure Device Update for IoT Hub client library for Python

The library provides access to the Device Update for IoT Hub service that enables customers to publish updates for their IoT devices to the cloud, and then deploy these updates to their devices (approve updates to groups of devices managed and provisioned in IoT Hub).

[Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/deviceupdate/azure-iot-deviceupdate) | [Package (PyPI)](https://aka.ms/azsdk/python/deviceupdate-pypi) | [Product documentation](https://docs.microsoft.com/azure/iot-hub-device-update/understand-device-update)

## Getting started

### Prerequisites

- Microsoft Azure Subscription: To call Microsoft Azure services, you need to create an [Azure subscription](https://azure.microsoft.com/free/)
- Device Update for IoT Hub instance
- Azure IoT Hub instance
- Python 2.7, or 3.6 or later is required to use this package.

### Install the package

Install the Device Update for IoT Hub client library for Python with [pip](https://pypi.org/project/pip/):

```bash
pip install azure-iot-deviceupdate --pre
```

## Key concepts

Device Update for IoT Hub is a managed service that enables you to deploy over-the-air updates for your IoT devices. The client library has one main component named **AzureDeviceUpdateServiceDataPlane**. The component allows you to access all three main client services:

- **UpdatesOperations**: update management (import, enumerate, delete, etc.)
- **DevicesOperations**: device management (enumerate devices and retrieve device properties)
- **DeploymentsOperations**: deployment management (start and monitor update deployments to a set of devices)

You can learn more about Device Update for IoT Hub by visiting [Device Update for IoT Hub](https://github.com/azure/iot-hub-device-update).

## Examples

You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/deviceupdate/azure-iot-deviceupdate/samples).

## Troubleshooting

The Device Update for IoT Hub client will raise exceptions defined in [Azure Core][https://github.com/azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/readme.md].

## Next steps

Get started with our [Device Update for IoT Hub samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/deviceupdate/azure-iot-deviceupdate/samples)

## Contributing

If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project.

<!-- LINKS -->
[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md
1 change: 1 addition & 0 deletions sdk/deviceupdate/azure-iot-deviceupdate/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._device_update_client import DeviceUpdateClient
from ._version import VERSION

__version__ = VERSION
__all__ = ['DeviceUpdateClient']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.credentials import TokenCredential


class DeviceUpdateClientConfiguration(Configuration):
"""Configuration for DeviceUpdateClient.

Note that all parameters used to create this instance are saved as instance
attributes.

:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param account_endpoint: Account endpoint.
:type account_endpoint: str
:param instance_id: Account instance identifier.
:type instance_id: str
"""

def __init__(
self,
credential, # type: "TokenCredential"
account_endpoint, # type: str
instance_id, # type: str
**kwargs # type: Any
):
# type: (...) -> None
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
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.")
super(DeviceUpdateClientConfiguration, self).__init__(**kwargs)

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

def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING

from azure.core import PipelineClient
from msrest import Deserializer, Serializer

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.credentials import TokenCredential
from azure.core.pipeline.transport import HttpRequest, HttpResponse

from ._configuration import DeviceUpdateClientConfiguration
from .operations import UpdatesOperations
from .operations import DevicesOperations
from .operations import DeploymentsOperations
from . import models


class DeviceUpdateClient(object):
"""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 updates: UpdatesOperations operations
:vartype updates: azure.iot.deviceupdate.operations.UpdatesOperations
:ivar devices: DevicesOperations operations
:vartype devices: azure.iot.deviceupdate.operations.DevicesOperations
:ivar deployments: DeploymentsOperations operations
:vartype deployments: azure.iot.deviceupdate.operations.DeploymentsOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param account_endpoint: Account endpoint.
:type account_endpoint: str
:param instance_id: Account instance identifier.
:type instance_id: str
"""

def __init__(
self,
credential, # type: "TokenCredential"
account_endpoint, # type: str
instance_id, # type: str
**kwargs # type: Any
):
# type: (...) -> None
base_url = 'https://{accountEndpoint}'
self._config = DeviceUpdateClientConfiguration(credential, account_endpoint, instance_id, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
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)

def _send_request(self, http_request, **kwargs):
# type: (HttpRequest, Any) -> HttpResponse
"""Runs the network request through the client's chained policies.

:param http_request: The network request you want to make. Required.
:type http_request: ~azure.core.pipeline.transport.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.pipeline.transport.HttpResponse
"""
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.instance_id", self._config.instance_id, 'str', skip_quote=True),
}
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
stream = kwargs.pop("stream", True)
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

def close(self):
# type: () -> None
self._client.close()

def __enter__(self):
# type: () -> DeviceUpdateClient
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "1.0.0b1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._device_update_client import DeviceUpdateClient
__all__ = ['DeviceUpdateClient']
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from .._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential


class DeviceUpdateClientConfiguration(Configuration):
"""Configuration for DeviceUpdateClient.

Note that all parameters used to create this instance are saved as instance
attributes.

:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param account_endpoint: Account endpoint.
:type account_endpoint: str
:param instance_id: Account instance identifier.
:type instance_id: str
"""

def __init__(
self,
credential: "AsyncTokenCredential",
account_endpoint: str,
instance_id: str,
**kwargs: Any
) -> None:
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
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.")
super(DeviceUpdateClientConfiguration, self).__init__(**kwargs)

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

def _configure(
self,
**kwargs: Any
) -> None:
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Loading