Skip to content

Commit 79e44ff

Browse files
author
David Pokluda
committed
Release of Device Update for IoT Hub SDK for Python.
1 parent 87ec5bf commit 79e44ff

File tree

81 files changed

+14207
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+14207
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Release History
2+
3+
## 0.0.0.1 (2020-09-01)
4+
- Initial Release
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include *.md
2+
include azure/__init__.py
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Device Update for IoT Hub client library for Python
2+
3+
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).
4+
5+
[Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/deviceupdate) | [Package (PyPI)](https://pypi.org/project/azure-deviceupdate/) | [Product documentation](https://github.com/Azure/adu-private-preview/blob/master/docs/adu-overview.md)
6+
7+
## Getting started
8+
9+
### Prerequisites
10+
11+
- Microsoft Azure Subscription: To call Microsoft Azure services, you need to create an [Azure subscription](https://azure.microsoft.com/free/)
12+
- Device Update for IoT Hub instance
13+
- Azure IoT Hub instance
14+
- Python 2.7, or 3.5 or later is required to use this package.
15+
16+
### Install the package
17+
18+
Install the Device Update for IoT Hub client library for Python with [pip](https://pypi.org/project/pip/):
19+
20+
```bash
21+
pip install azure-deviceupdate --pre
22+
```
23+
24+
## Key concepts
25+
26+
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:
27+
- **UpdatesOperations**: update management (import, enumerate, delete, etc.)
28+
- **DevicesOperations**: device management (enumerate devices and retrieve device properties)
29+
- **DeploymentsOperations**: deployment management (start and monitor update deployments to a set of devices)
30+
31+
You can learn more about Device Update for IoT Hub by visiting [Device Update for IoT Hub](https://github.com/Azure/adu-private-preview/tree/release/v0.2.0-private-preview).
32+
33+
## Examples
34+
35+
You can familiarize yourself with different APIs using [Samples](./samples).
36+
37+
## Troubleshooting
38+
39+
The Device Update for IoT Hub client will raise exceptions defined in [Azure Core][azure_core].
40+
41+
## Next steps
42+
43+
Get started with our [Device Update for IoT Hub samples](./samples)
44+
45+
## Contributing
46+
47+
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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# --------------------------------------------------------------------------
7+
8+
from ._device_update_client import DeviceUpdateClient
9+
from ._version import VERSION
10+
11+
__version__ = VERSION
12+
__all__ = ['DeviceUpdateClient']
13+
14+
try:
15+
from ._patch import patch_sdk # type: ignore
16+
patch_sdk()
17+
except ImportError:
18+
pass
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# --------------------------------------------------------------------------
7+
8+
from typing import TYPE_CHECKING
9+
10+
from azure.core.configuration import Configuration
11+
from azure.core.pipeline import policies
12+
13+
from ._version import VERSION
14+
15+
if TYPE_CHECKING:
16+
# pylint: disable=unused-import,ungrouped-imports
17+
from typing import Any
18+
19+
from azure.core.credentials import TokenCredential
20+
21+
22+
class DeviceUpdateClientConfiguration(Configuration):
23+
"""Configuration for DeviceUpdateClient.
24+
25+
Note that all parameters used to create this instance are saved as instance
26+
attributes.
27+
28+
:param credential: Credential needed for the client to connect to Azure.
29+
:type credential: ~azure.core.credentials.TokenCredential
30+
:param account_endpoint: Account endpoint.
31+
:type account_endpoint: str
32+
:param instance_id: Account instance identifier.
33+
:type instance_id: str
34+
"""
35+
36+
def __init__(
37+
self,
38+
credential, # type: "TokenCredential"
39+
account_endpoint, # type: str
40+
instance_id, # type: str
41+
**kwargs # type: Any
42+
):
43+
# type: (...) -> None
44+
if credential is None:
45+
raise ValueError("Parameter 'credential' must not be None.")
46+
if account_endpoint is None:
47+
raise ValueError("Parameter 'account_endpoint' must not be None.")
48+
if instance_id is None:
49+
raise ValueError("Parameter 'instance_id' must not be None.")
50+
super(DeviceUpdateClientConfiguration, self).__init__(**kwargs)
51+
52+
self.credential = credential
53+
self.account_endpoint = account_endpoint
54+
self.instance_id = instance_id
55+
self.credential_scopes = kwargs.pop('credential_scopes', ['6ee392c4-d339-4083-b04d-6b7947c6cf78/.default'])
56+
kwargs.setdefault('sdk_moniker', 'deviceupdate/{}'.format(VERSION))
57+
self._configure(**kwargs)
58+
59+
def _configure(
60+
self,
61+
**kwargs # type: Any
62+
):
63+
# type: (...) -> None
64+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
65+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
66+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
67+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
68+
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
69+
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
70+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
71+
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
72+
self.authentication_policy = kwargs.get('authentication_policy')
73+
if self.credential and not self.authentication_policy:
74+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# --------------------------------------------------------------------------
7+
8+
from typing import TYPE_CHECKING
9+
10+
from azure.core import PipelineClient
11+
from msrest import Deserializer, Serializer
12+
13+
if TYPE_CHECKING:
14+
# pylint: disable=unused-import,ungrouped-imports
15+
from typing import Any
16+
17+
from azure.core.credentials import TokenCredential
18+
19+
from ._configuration import DeviceUpdateClientConfiguration
20+
from .operations import UpdatesOperations
21+
from .operations import DevicesOperations
22+
from .operations import DeploymentsOperations
23+
from . import models
24+
25+
26+
class DeviceUpdateClient(object):
27+
"""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.
28+
29+
:ivar updates: UpdatesOperations operations
30+
:vartype updates: azure.deviceupdate.operations.UpdatesOperations
31+
:ivar devices: DevicesOperations operations
32+
:vartype devices: azure.deviceupdate.operations.DevicesOperations
33+
:ivar deployments: DeploymentsOperations operations
34+
:vartype deployments: azure.deviceupdate.operations.DeploymentsOperations
35+
:param credential: Credential needed for the client to connect to Azure.
36+
:type credential: ~azure.core.credentials.TokenCredential
37+
:param account_endpoint: Account endpoint.
38+
:type account_endpoint: str
39+
:param instance_id: Account instance identifier.
40+
:type instance_id: str
41+
"""
42+
43+
def __init__(
44+
self,
45+
credential, # type: "TokenCredential"
46+
account_endpoint, # type: str
47+
instance_id, # type: str
48+
**kwargs # type: Any
49+
):
50+
# type: (...) -> None
51+
base_url = 'https://{accountEndpoint}'
52+
self._config = DeviceUpdateClientConfiguration(credential, account_endpoint, instance_id, **kwargs)
53+
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
54+
55+
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
56+
self._serialize = Serializer(client_models)
57+
self._serialize.client_side_validation = False
58+
self._deserialize = Deserializer(client_models)
59+
60+
self.updates = UpdatesOperations(
61+
self._client, self._config, self._serialize, self._deserialize)
62+
self.devices = DevicesOperations(
63+
self._client, self._config, self._serialize, self._deserialize)
64+
self.deployments = DeploymentsOperations(
65+
self._client, self._config, self._serialize, self._deserialize)
66+
67+
def close(self):
68+
# type: () -> None
69+
self._client.close()
70+
71+
def __enter__(self):
72+
# type: () -> DeviceUpdateClient
73+
self._client.__enter__()
74+
return self
75+
76+
def __exit__(self, *exc_details):
77+
# type: (Any) -> None
78+
self._client.__exit__(*exc_details)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# --------------------------------------------------------------------------
7+
8+
VERSION = "2020-09-01-preview"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# --------------------------------------------------------------------------
7+
8+
from ._device_update_client import DeviceUpdateClient
9+
__all__ = ['DeviceUpdateClient']
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# --------------------------------------------------------------------------
7+
8+
from typing import Any, TYPE_CHECKING
9+
10+
from azure.core.configuration import Configuration
11+
from azure.core.pipeline import policies
12+
13+
from .._version import VERSION
14+
15+
if TYPE_CHECKING:
16+
# pylint: disable=unused-import,ungrouped-imports
17+
from azure.core.credentials_async import AsyncTokenCredential
18+
19+
20+
class DeviceUpdateClientConfiguration(Configuration):
21+
"""Configuration for DeviceUpdateClient.
22+
23+
Note that all parameters used to create this instance are saved as instance
24+
attributes.
25+
26+
:param credential: Credential needed for the client to connect to Azure.
27+
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
28+
:param account_endpoint: Account endpoint.
29+
:type account_endpoint: str
30+
:param instance_id: Account instance identifier.
31+
:type instance_id: str
32+
"""
33+
34+
def __init__(
35+
self,
36+
credential: "AsyncTokenCredential",
37+
account_endpoint: str,
38+
instance_id: str,
39+
**kwargs: Any
40+
) -> None:
41+
if credential is None:
42+
raise ValueError("Parameter 'credential' must not be None.")
43+
if account_endpoint is None:
44+
raise ValueError("Parameter 'account_endpoint' must not be None.")
45+
if instance_id is None:
46+
raise ValueError("Parameter 'instance_id' must not be None.")
47+
super(DeviceUpdateClientConfiguration, self).__init__(**kwargs)
48+
49+
self.credential = credential
50+
self.account_endpoint = account_endpoint
51+
self.instance_id = instance_id
52+
self.credential_scopes = kwargs.pop('credential_scopes', ['6ee392c4-d339-4083-b04d-6b7947c6cf78/.default'])
53+
kwargs.setdefault('sdk_moniker', 'deviceupdate/{}'.format(VERSION))
54+
self._configure(**kwargs)
55+
56+
def _configure(
57+
self,
58+
**kwargs: Any
59+
) -> None:
60+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
61+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
62+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
63+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
64+
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
65+
self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
66+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
67+
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
68+
self.authentication_policy = kwargs.get('authentication_policy')
69+
if self.credential and not self.authentication_policy:
70+
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# --------------------------------------------------------------------------
7+
8+
from typing import Any, TYPE_CHECKING
9+
10+
from azure.core import AsyncPipelineClient
11+
from msrest import Deserializer, Serializer
12+
13+
if TYPE_CHECKING:
14+
# pylint: disable=unused-import,ungrouped-imports
15+
from azure.core.credentials_async import AsyncTokenCredential
16+
17+
from ._configuration import DeviceUpdateClientConfiguration
18+
from .operations import UpdatesOperations
19+
from .operations import DevicesOperations
20+
from .operations import DeploymentsOperations
21+
from .. import models
22+
23+
24+
class DeviceUpdateClient(object):
25+
"""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.
26+
27+
:ivar updates: UpdatesOperations operations
28+
:vartype updates: azure.deviceupdate.aio.operations.UpdatesOperations
29+
:ivar devices: DevicesOperations operations
30+
:vartype devices: azure.deviceupdate.aio.operations.DevicesOperations
31+
:ivar deployments: DeploymentsOperations operations
32+
:vartype deployments: azure.deviceupdate.aio.operations.DeploymentsOperations
33+
:param credential: Credential needed for the client to connect to Azure.
34+
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
35+
:param account_endpoint: Account endpoint.
36+
:type account_endpoint: str
37+
:param instance_id: Account instance identifier.
38+
:type instance_id: str
39+
"""
40+
41+
def __init__(
42+
self,
43+
credential: "AsyncTokenCredential",
44+
account_endpoint: str,
45+
instance_id: str,
46+
**kwargs: Any
47+
) -> None:
48+
base_url = 'https://{accountEndpoint}'
49+
self._config = DeviceUpdateClientConfiguration(credential, account_endpoint, instance_id, **kwargs)
50+
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)
51+
52+
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
53+
self._serialize = Serializer(client_models)
54+
self._serialize.client_side_validation = False
55+
self._deserialize = Deserializer(client_models)
56+
57+
self.updates = UpdatesOperations(
58+
self._client, self._config, self._serialize, self._deserialize)
59+
self.devices = DevicesOperations(
60+
self._client, self._config, self._serialize, self._deserialize)
61+
self.deployments = DeploymentsOperations(
62+
self._client, self._config, self._serialize, self._deserialize)
63+
64+
async def close(self) -> None:
65+
await self._client.close()
66+
67+
async def __aenter__(self) -> "DeviceUpdateClient":
68+
await self._client.__aenter__()
69+
return self
70+
71+
async def __aexit__(self, *exc_details) -> None:
72+
await self._client.__aexit__(*exc_details)

0 commit comments

Comments
 (0)