-
Notifications
You must be signed in to change notification settings - Fork 3k
Release of Device Update for IoT Hub SDK for Python. #17005
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
Merged
Merged
Changes from 15 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.
25d66c9
Updating the generated code, sample, tests and recorded sessions.
a6a2aea
update links, manifest, and allow pylint failures
iscai-msft 8e41822
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
4da7534
Updated readme links.
32002e2
fix dev_requirements
iscai-msft f7ff895
Merge branch 'device-update' of https://github.com/dpokluda/azure-sdk…
iscai-msft e3ffa53
remove en-us from link in readme
iscai-msft 6f8fc1a
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
iscai-msft 1024efd
switch to powershell preparer, all passing in playback except one
iscai-msft 246afaa
remove tests. and test_data
iscai-msft 7b8ee32
add Azure to top of readme
iscai-msft b07ca58
change device update core requirement in shared_requirements.txt
iscai-msft aff03ef
mark scrubbing failure test with live only
iscai-msft 5c62fdd
update date in changelog
iscai-msft 7056987
make changes to readme links and setup.py
iscai-msft 68987bc
switch credential scopes and re-reocrd tests
iscai-msft eb19425
mark test as live only
iscai-msft d062d09
remove timezone from tests
iscai-msft 6312c0b
remove mention of 3.5 in readme
iscai-msft bafea96
Update sample.py
dpokluda 6af10f9
Merge branch 'device-update' of https://github.com/dpokluda/azure-sdk…
dpokluda 5cbd40f
add azure-iot-nspkg to shared_requirements
iscai-msft 91faabd
Merge branch 'device-update' of https://github.com/dpokluda/azure-sdk…
iscai-msft ab653a0
Update CHANGELOG.md
dpokluda 62f2894
Tweaking sample argument parsing.
dpokluda 7457de0
Updated samples output
dpokluda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Release History | ||
|
||
## 1.0.0b1 (2021-03-03) | ||
- Initial Release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | [Package (PyPI)](https://aka.ms/azsdk/python/) | [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.5 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). | ||
|
||
## 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) | ||
|
||
## 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore |
19 changes: 19 additions & 0 deletions
19
sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
75 changes: 75 additions & 0 deletions
75
sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_configuration.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', ['6ee392c4-d339-4083-b04d-6b7947c6cf78/.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) |
99 changes: 99 additions & 0 deletions
99
sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_device_update_client.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
9 changes: 9 additions & 0 deletions
9
sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_version.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
10 changes: 10 additions & 0 deletions
10
sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
71 changes: 71 additions & 0 deletions
71
sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/aio/_configuration.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', ['6ee392c4-d339-4083-b04d-6b7947c6cf78/.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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.