chore: Restructure repository for single project (#1030)
Moved from monorepo style project to src style project
4
.flake8
|
@ -6,6 +6,4 @@ ignore = E501,W503,E203
|
|||
exclude =
|
||||
.git,
|
||||
__pycache__,
|
||||
./azure-iot-provisioning-servicesdk/azure/iot/provisioning/servicesdk/protocol/models
|
||||
./azure-iot-hub/azure/iot/hub/protocol
|
||||
./azure_provisioning_e2e/iothubservice20180630/
|
||||
tests/e2e/provisioning_e2e/iothubservice20180630/*
|
||||
|
|
186
README.md
|
@ -1,26 +1,82 @@
|
|||
#
|
||||
<div align=center>
|
||||
<img src="./azure-iot-device/doc/images/azure_iot_sdk_python_banner.png"></img>
|
||||
<h1> V2 - We are now GA! </h1>
|
||||
<h1> azure-iot-device </h1>
|
||||
</div>
|
||||
|
||||
![Build Status](https://azure-iot-sdks.visualstudio.com/azure-iot-sdks/_apis/build/status/Azure.azure-iot-sdk-python)
|
||||
|
||||
This repository contains code for the Azure IoT SDKs for Python. This enables python developers to easily create IoT device solutions that seamlessly
|
||||
connect to the Azure IoT Hub ecosystem.
|
||||
The Azure IoT Device SDK for Python enables Python developers to easily create IoT device solutions that seamlessly connect to the Azure IoT Hub ecosystem.
|
||||
|
||||
*If you're looking for the v1.x.x client library, it is now preserved in the [v1-deprecated](https://github.com/Azure/azure-iot-sdk-python/tree/v1-deprecated) branch.*
|
||||
* *If you're looking for the azure-iot-hub library, it is now located in the [azure-iot-hub-python](https://github.com/Azure/azure-iot-hub-python) repository*
|
||||
|
||||
## Azure IoT SDK for Python
|
||||
* *If you're looking for the v1.x.x client library, it is now preserved in the [v1-deprecated](https://github.com/Azure/azure-iot-sdk-python/tree/v1-deprecated) branch.*
|
||||
|
||||
This repository contains the following libraries:
|
||||
|
||||
* [Azure IoT Device library](https://github.com/Azure/azure-iot-sdk-python/blob/main/azure-iot-device/README.md).
|
||||
* [API Reference](https://docs.microsoft.com/en-us/python/api/azure-iot-device)
|
||||
## Installing the library
|
||||
|
||||
* [Azure IoT Hub Service library](https://github.com/Azure/azure-iot-sdk-python/blob/main/azure-iot-hub/README.md)
|
||||
* [API Reference](https://docs.microsoft.com/en-us/python/api/azure-iot-hub)
|
||||
The Azure IoT Device library is available on PyPI:
|
||||
|
||||
```Shell
|
||||
pip install azure-iot-device
|
||||
```
|
||||
|
||||
Python 3.6 or higher is required in order to use the library
|
||||
|
||||
## Using the library
|
||||
API documentation for this package is available via [**Microsoft Docs**](https://docs.microsoft.com/python/api/azure-iot-device/azure.iot.device?view=azure-python).
|
||||
|
||||
See our [**quickstart guide**](https://github.com/Azure/azure-iot-sdk-python/tree/main/samples/README.md) for step by step instructions for setting up and using an IoTHub with devices.
|
||||
|
||||
You can also view the [**samples repository**](https://github.com/Azure/azure-iot-sdk-python/tree/main/samples) to see additional examples of basic client usage.
|
||||
|
||||
Want to start off on the right foot? Be sure to learn about [**common pitfalls**](https://github.com/Azure/azure-iot-sdk-python/wiki/pitfalls) of using this Python SDK before starting a project.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
:heavy_check_mark: feature available :heavy_multiplication_x: feature planned but not yet supported :heavy_minus_sign: no support planned*
|
||||
|
||||
*Features that are not planned may be prioritized in a future release, but are not currently planned
|
||||
|
||||
These clients only support the **MQTT protocol**.
|
||||
|
||||
### IoTHub Device Client
|
||||
|
||||
| Features | Status | Description |
|
||||
|------------------------------------------------------------------------------------------------------------------|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [Authentication](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-security-deployment) | :heavy_check_mark: | Connect your device to IoT Hub securely with supported authentication, including symmetric key, X-509 Self Signed, Certificate Authority (CA) Signed, and SASToken |
|
||||
| [Send device-to-cloud message](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-d2c) | :heavy_check_mark: | Send device-to-cloud messages (max 256KB) to IoT Hub with the option to add custom properties. |
|
||||
| [Receive cloud-to-device messages](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-c2d) | :heavy_check_mark: | Receive cloud-to-device messages and read associated custom and system properties from IoT Hub, with the option to complete/reject/abandon C2D messages. |
|
||||
| [Device Twins](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-device-twins) | :heavy_check_mark: | IoT Hub persists a device twin for each device that you connect to IoT Hub. The device can perform operations like get twin tags, subscribe to desired properties. |
|
||||
| [Direct Methods](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-direct-methods) | :heavy_check_mark: | IoT Hub gives you the ability to invoke direct methods on devices from the cloud. The SDK supports handler for method specific and generic operation. |
|
||||
| [Connection Status and Error reporting](https://docs.microsoft.com/en-us/rest/api/iothub/common-error-codes) | :heavy_check_mark: | Error reporting for IoT Hub supported error code. |
|
||||
| Connection Retry | :heavy_check_mark: | Dropped connections will be retried with a fixed 10 second interval by default. This functionality can be disabled if desired, and the interval can be configured |
|
||||
| [Upload file to Blob](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload) | :heavy_check_mark: | A device can initiate a file upload and notifies IoT Hub when the upload is complete. |
|
||||
|
||||
### IoTHub Module Client
|
||||
|
||||
**Note:** IoT Edge for Python is scoped to Linux containers & devices only. [Learn more](https://techcommunity.microsoft.com/t5/internet-of-things/linux-modules-with-azure-iot-edge-on-windows-10-iot-enterprise/ba-p/1407066) about using Linux containers for IoT edge on Windows devices.
|
||||
|
||||
| Features | Status | Description |
|
||||
|------------------------------------------------------------------------------------------------------------------|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [Authentication](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-security-deployment) | :heavy_check_mark: | Connect your device to IoT Hub securely with supported authentication, including symmetric key, X-509 Self Signed, and Certificate Authority (CA) Signed. SASToken authentication is not currently supported. |
|
||||
| [Send device-to-cloud message](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-d2c) | :heavy_check_mark: | Send device-to-cloud messages (max 256KB) to IoT Hub with the option to add custom properties. |
|
||||
| [Receive cloud-to-device messages](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-c2d) | :heavy_check_mark: | Receive cloud-to-device messages and read associated custom and system properties from IoT Hub, with the option to complete/reject/abandon C2D messages. |
|
||||
| [Device Twins](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-device-twins) | :heavy_check_mark: | IoT Hub persists a device twin for each device that you connect to IoT Hub. The device can perform operations like get twin tags, subscribe to desired properties. |
|
||||
| [Direct Methods](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-direct-methods) | :heavy_check_mark: | IoT Hub gives you the ability to invoke direct methods on devices from the cloud. The SDK supports handler for method specific and generic operation. |
|
||||
| [Connection Status and Error reporting](https://docs.microsoft.com/en-us/rest/api/iothub/common-error-codes) | :heavy_check_mark: | Error reporting for IoT Hub supported error code. |
|
||||
| Connection Retry | :heavy_check_mark: | Dropped connections will be retried with a fixed 10 second interval. TThis functionality can be disabled if desired, and the interval can be configured |
|
||||
| Direct Invocation of Method on Modules | :heavy_check_mark: | Invoke method calls to another module using using the Edge Gateway. |
|
||||
|
||||
### Provisioning Device Client
|
||||
|
||||
| Features | Status | Description |
|
||||
|-----------------------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| TPM Individual Enrollment | :heavy_minus_sign: | Provisioning via [Trusted Platform Module](https://docs.microsoft.com/en-us/azure/iot-dps/concepts-security#trusted-platform-module-tpm). |
|
||||
| X.509 Individual Enrollment | :heavy_check_mark: | Provisioning via [X.509 root certificate](https://docs.microsoft.com/en-us/azure/iot-dps/concepts-security#root-certificate). Please review the [samples](azure-iot-device/samples/async-hub-scenarios/provision_x509.py) folder and this [quickstart](https://docs.microsoft.com/en-us/azure/iot-dps/quick-create-simulated-device-x509-python) on how to create a device client. |
|
||||
| X.509 Enrollment Group | :heavy_check_mark: | Provisioning via [X.509 leaf certificate](https://docs.microsoft.com/en-us/azure/iot-dps/concepts-security#leaf-certificate)). Please review the [samples](azure-iot-device/samples/async-hub-scenarios/provision_x509.py) folder on how to create a device client. |
|
||||
| Symmetric Key Enrollment | :heavy_check_mark: | Provisioning via [Symmetric key attestation](https://docs.microsoft.com/en-us/azure/iot-dps/concepts-symmetric-key-attestation)). Please review the [samples](azure-iot-device/samples/async-hub-scenarios/provision_symmetric_key.py) folder on how to create a device client. |
|
||||
|
||||
## Critical Upcoming Changes Notice
|
||||
|
||||
|
@ -40,116 +96,6 @@ For a more in depth explanation as to why the IoT services are doing this, pleas
|
|||
[this article](https://techcommunity.microsoft.com/t5/internet-of-things/azure-iot-tls-critical-changes-are-almost-here-and-why-you/ba-p/2393169).
|
||||
|
||||
|
||||
## Installing the libraries
|
||||
|
||||
Pip installs are provided for all of the SDK libraries in this repo:
|
||||
|
||||
[Device Client libraries](https://github.com/Azure/azure-iot-sdk-python/tree/main/azure-iot-device#installation)
|
||||
|
||||
[IoTHub Service library](https://github.com/Azure/azure-iot-sdk-python/blob/main/azure-iot-hub/README.md#installation)
|
||||
|
||||
## Using the libraries
|
||||
Want to start off on the right foot? Be sure to learn about [**common pitfalls**](https://github.com/Azure/azure-iot-sdk-python/wiki/pitfalls) of using this Python SDK before starting a project.
|
||||
|
||||
You can also view samples in each library:
|
||||
- [Device Client Samples](https://github.com/Azure/azure-iot-sdk-python/tree/main/azure-iot-device/samples) cover device and Edge module scenarios.
|
||||
- [IoTHub Service Samples](https://github.com/Azure/azure-iot-sdk-python/tree/main/azure-iot-hub/samples) cover IoT Hub service side scenarios.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
:heavy_check_mark: feature available :heavy_multiplication_x: feature planned but not yet supported :heavy_minus_sign: no support planned*
|
||||
|
||||
*Features that are not planned may be prioritized in a future release, but are not currently planned
|
||||
|
||||
This SDK only supports the **MQTT protocol**.
|
||||
|
||||
### Device Client Library ([azure-iot-device](https://github.com/Azure/azure-iot-sdk-python/tree/main/azure-iot-device))
|
||||
|
||||
#### IoTHub Device Client
|
||||
|
||||
| Features | Status | Description |
|
||||
|------------------------------------------------------------------------------------------------------------------|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [Authentication](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-security-deployment) | :heavy_check_mark: | Connect your device to IoT Hub securely with supported authentication, including symmetric key, X-509 Self Signed, Certificate Authority (CA) Signed, and SASToken |
|
||||
| [Send device-to-cloud message](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-d2c) | :heavy_check_mark: | Send device-to-cloud messages (max 256KB) to IoT Hub with the option to add custom properties. |
|
||||
| [Receive cloud-to-device messages](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-c2d) | :heavy_check_mark: | Receive cloud-to-device messages and read associated custom and system properties from IoT Hub, with the option to complete/reject/abandon C2D messages. |
|
||||
| [Device Twins](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-device-twins) | :heavy_check_mark: | IoT Hub persists a device twin for each device that you connect to IoT Hub. The device can perform operations like get twin tags, subscribe to desired properties. |
|
||||
| [Direct Methods](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-direct-methods) | :heavy_check_mark: | IoT Hub gives you the ability to invoke direct methods on devices from the cloud. The SDK supports handler for method specific and generic operation. |
|
||||
| [Connection Status and Error reporting](https://docs.microsoft.com/en-us/rest/api/iothub/common-error-codes) | :heavy_check_mark: | Error reporting for IoT Hub supported error code. |
|
||||
| Connection Retry | :heavy_check_mark: | Dropped connections will be retried with a fixed 10 second interval by default. This functionality can be disabled if desired, and the interval can be configured |
|
||||
| [Upload file to Blob](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload) | :heavy_check_mark: | A device can initiate a file upload and notifies IoT Hub when the upload is complete. |
|
||||
|
||||
#### IoTHub Module Client
|
||||
|
||||
**Note:** IoT Edge for Python is scoped to Linux containers & devices only. [Learn more](https://techcommunity.microsoft.com/t5/internet-of-things/linux-modules-with-azure-iot-edge-on-windows-10-iot-enterprise/ba-p/1407066) about using Linux containers for IoT edge on Windows devices.
|
||||
|
||||
| Features | Status | Description |
|
||||
|------------------------------------------------------------------------------------------------------------------|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [Authentication](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-security-deployment) | :heavy_check_mark: | Connect your device to IoT Hub securely with supported authentication, including symmetric key, X-509 Self Signed, and Certificate Authority (CA) Signed. SASToken authentication is not currently supported. |
|
||||
| [Send device-to-cloud message](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-d2c) | :heavy_check_mark: | Send device-to-cloud messages (max 256KB) to IoT Hub with the option to add custom properties. |
|
||||
| [Receive cloud-to-device messages](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-c2d) | :heavy_check_mark: | Receive cloud-to-device messages and read associated custom and system properties from IoT Hub, with the option to complete/reject/abandon C2D messages. |
|
||||
| [Device Twins](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-device-twins) | :heavy_check_mark: | IoT Hub persists a device twin for each device that you connect to IoT Hub. The device can perform operations like get twin tags, subscribe to desired properties. |
|
||||
| [Direct Methods](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-direct-methods) | :heavy_check_mark: | IoT Hub gives you the ability to invoke direct methods on devices from the cloud. The SDK supports handler for method specific and generic operation. |
|
||||
| [Connection Status and Error reporting](https://docs.microsoft.com/en-us/rest/api/iothub/common-error-codes) | :heavy_check_mark: | Error reporting for IoT Hub supported error code. |
|
||||
| Connection Retry | :heavy_check_mark: | Dropped connections will be retried with a fixed 10 second interval. TThis functionality can be disabled if desired, and the interval can be configured |
|
||||
| Direct Invocation of Method on Modules | :heavy_check_mark: | Invoke method calls to another module using using the Edge Gateway. |
|
||||
|
||||
#### Provisioning Device Client
|
||||
|
||||
| Features | Status | Description |
|
||||
|-----------------------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| TPM Individual Enrollment | :heavy_minus_sign: | Provisioning via [Trusted Platform Module](https://docs.microsoft.com/en-us/azure/iot-dps/concepts-security#trusted-platform-module-tpm). |
|
||||
| X.509 Individual Enrollment | :heavy_check_mark: | Provisioning via [X.509 root certificate](https://docs.microsoft.com/en-us/azure/iot-dps/concepts-security#root-certificate). Please review the [samples](azure-iot-device/samples/async-hub-scenarios/provision_x509.py) folder and this [quickstart](https://docs.microsoft.com/en-us/azure/iot-dps/quick-create-simulated-device-x509-python) on how to create a device client. |
|
||||
| X.509 Enrollment Group | :heavy_check_mark: | Provisioning via [X.509 leaf certificate](https://docs.microsoft.com/en-us/azure/iot-dps/concepts-security#leaf-certificate)). Please review the [samples](azure-iot-device/samples/async-hub-scenarios/provision_x509.py) folder on how to create a device client. |
|
||||
| Symmetric Key Enrollment | :heavy_check_mark: | Provisioning via [Symmetric key attestation](https://docs.microsoft.com/en-us/azure/iot-dps/concepts-symmetric-key-attestation)). Please review the [samples](azure-iot-device/samples/async-hub-scenarios/provision_symmetric_key.py) folder on how to create a device client. |
|
||||
|
||||
### IoTHub Service Library ([azure-iot-hub](https://github.com/Azure/azure-iot-sdk-python/blob/main/azure-iot-hub/azure/iot/hub/iothub_registry_manager.py))
|
||||
|
||||
#### Registry Manager
|
||||
|
||||
| Features | Status | Description |
|
||||
|---------------------------------------------------------------------------------------------------------------|--------------------------|------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [Identity registry (CRUD)](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry) | :heavy_check_mark: | Use your backend app to perform CRUD operation for individual device or in bulk. |
|
||||
| [Cloud-to-device messaging](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-c2d) | :heavy_check_mark: | Use your backend app to send cloud-to-device messages, and set up cloud-to-device message receivers. |
|
||||
| [Direct Methods operations](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-direct-methods) | :heavy_check_mark: | Use your backend app to invoke direct method on device. |
|
||||
| [Device Twins operations](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-device-twins) | :heavy_check_mark: | Use your backend app to perform device twin operations. *Twin reported property update callback and replace twin are in progress. |
|
||||
| [Query](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-query-language) | :heavy_check_mark: | Use your backend app to perform query for information. |
|
||||
| [Jobs](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-jobs) | :heavy_multiplication_x: | Use your backend app to perform job operation. |
|
||||
|
||||
|
||||
# Releases
|
||||
|
||||
The Pythond SDK offers releases for new features, critical bug fixes, and Long Term Support (LTS). Versioning follows [semantic versioning](https://semver.org/), `x.y.z.` or `major.minor.patch`. Any time the version is updated, it will be tagged `x.y.z`.
|
||||
|
||||
## New Features and Critical Bug Fixes
|
||||
|
||||
New features and critical bug fixes (including security updates) will be released on the main branch. These releases will be tagged using the date formatted `yyyy-mm-dd`. A feature release will bump the `minor` version and reset the `patch` version to 0. A critical bug fix will bump the `patch` version only.
|
||||
|
||||
## Long Term Support (LTS)
|
||||
|
||||
The project offers a Long Term Support (LTS) version to allow users that do not need the latest features to be shielded from unwanted changes.
|
||||
|
||||
LTS branches receive all bug fixes that fall in one of these categories:
|
||||
|
||||
- security bugfixes
|
||||
- critical bugfixes (crashes, memory leaks, etc.)
|
||||
|
||||
No new features or improvements will be picked up in an LTS branch.
|
||||
|
||||
LTS branches are named `lts_mm_yyyy`, where *mm* and *yyyy* are the month and year when the branch was created. An example of such a branch is `lts_07_2017`.
|
||||
|
||||
### LTS Schedule<sup>1</sup>
|
||||
|
||||
*The first LTS version of the Python SDK is scheduled to be available in early 2022*
|
||||
|
||||
Below is a table showing the mapping of the LTS branches to the packages released.
|
||||
|
||||
| PIP Package | GitHub Branch | LTS Tag | LTS Start Date | Maintenance End Date |
|
||||
| :-----: | :-----------: | :-----: | :------------: | :------------------: |
|
||||
| N/A | | | | |
|
||||
|
||||
<sup>1</sup> All scheduled dates are subject to change by the Azure IoT SDK team.
|
||||
|
||||
## Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
|
@ -1,58 +0,0 @@
|
|||
# Azure IoT Device SDK
|
||||
|
||||
The Azure IoT Device SDK for Python provides functionality for communicating with the Azure IoT Hub for both Devices and Modules.
|
||||
|
||||
## Azure IoT Device Features
|
||||
|
||||
The SDK provides the following clients:
|
||||
|
||||
* ### Provisioning Device Client
|
||||
|
||||
* Creates a device identity on the Azure IoT Hub
|
||||
|
||||
* ### IoT Hub Device Client
|
||||
|
||||
* Send telemetry messages to Azure IoT Hub
|
||||
* Receive Cloud-to-Device (C2D) messages from the Azure IoT Hub
|
||||
* Receive and respond to direct method invocations from the Azure IoT Hub
|
||||
|
||||
* ### IoT Hub Module Client
|
||||
|
||||
* Supports Azure IoT Edge Hub and Azure IoT Hub
|
||||
* Send telemetry messages to a Hub or to another Module
|
||||
* Receive Input messages from a Hub or other Modules
|
||||
* Receive and respond to direct method invocations from a Hub or other Modules
|
||||
|
||||
These clients are available with an asynchronous API, as well as a blocking synchronous API.
|
||||
|
||||
## Requirements
|
||||
The Azure IoT Device SDK for Python requires Python 3.6+
|
||||
|
||||
## Installation
|
||||
|
||||
```Shell
|
||||
pip install azure-iot-device
|
||||
```
|
||||
|
||||
## Device Samples
|
||||
|
||||
Check out the [samples repository](https://github.com/Azure/azure-iot-sdk-python/tree/main/azure-iot-device/samples) for example code showing how the SDK can be used in a variety of scenarios, including:
|
||||
|
||||
* Sending multiple telemetry messages at once.
|
||||
* Receiving Cloud-to-Device messages.
|
||||
* Using Edge Modules with the Azure IoT Edge Hub.
|
||||
* Send and receive updates to device twin
|
||||
* Receive invocations to direct methods
|
||||
* Register a device with the Device Provisioning Service
|
||||
|
||||
## Getting help and finding API docs
|
||||
|
||||
API documentation for this package is available via [Microsoft Docs](https://docs.microsoft.com/python/api/azure-iot-device/azure.iot.device?view=azure-python)
|
||||
|
||||
Additionally, the SDK makes use of docstrings which means you can find API documentation directly through Python with use of the [help](https://docs.python.org/3/library/functions.html#help) command:
|
||||
|
||||
e.g.
|
||||
```python
|
||||
>>> from azure.iot.device import IoTHubDeviceClient
|
||||
>>> help(IoTHubDeviceClient)
|
||||
```
|
|
@ -1 +0,0 @@
|
|||
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
|
|
@ -1 +0,0 @@
|
|||
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
|
|
@ -1,20 +0,0 @@
|
|||
# -------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for
|
||||
# license information.
|
||||
# --------------------------------------------------------------------------
|
||||
"""Build all packages for distribution"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
from subprocess import check_call
|
||||
|
||||
if __name__ == "__main__":
|
||||
target_dir = "../dist"
|
||||
packages = [os.path.dirname(p) for p in glob.glob("azure*/setup.py")]
|
||||
for package_name in packages:
|
||||
command_sdist = "setup.py sdist --dist-dir={}".format(target_dir)
|
||||
command_bdist_wheel = "setup.py bdist_wheel --dist-dir={}".format(target_dir)
|
||||
check_call([sys.executable] + command_sdist.split(), cwd=package_name)
|
||||
check_call([sys.executable] + command_bdist_wheel.split(), cwd=package_name)
|
|
@ -2,43 +2,43 @@
|
|||
"tool": "Credential Scanner",
|
||||
"suppressions": [
|
||||
{
|
||||
"file": "\\azure_provisioning_e2e\\tests\\test_async_certificate_enrollments.py",
|
||||
"file": "\\tests\\e2e\\provisioning_e2e\\tests\\test_async_certificate_enrollments.py",
|
||||
"_justification": "Test containing fake passwords and keys"
|
||||
},
|
||||
{
|
||||
"file": "\\azure_provisioning_e2e\\tests\\test_sync_certificate_enrollments.py",
|
||||
"file": "\\tests\\e2e\\provisioning_e2e\\tests\\test_sync_certificate_enrollments.py",
|
||||
"_justification": "Test containing fake passwords and keys"
|
||||
},
|
||||
{
|
||||
"file": "\\azure-iot-device\\tests\\common\\auth\\test_signing_mechanism.py",
|
||||
"file": "\\tests\\common\\auth\\test_signing_mechanism.py",
|
||||
"_justification": "Test containing fake keys"
|
||||
},
|
||||
{
|
||||
"file": "\\azure-iot-device\\tests\\common\\auth\\test_sastoken.py",
|
||||
"file": "\\tests\\common\\auth\\test_sastoken.py",
|
||||
"_justification": "Test containing fake signed data"
|
||||
},
|
||||
{
|
||||
"file": "\\azure-iot-device\\tests\\common\\test_mqtt_transport.py",
|
||||
"file": "\\tests\\common\\test_mqtt_transport.py",
|
||||
"_justification": "Test containing fake passwords"
|
||||
},
|
||||
{
|
||||
"file": "\\azure-iot-device\\tests\\common\\test_http_transport.py",
|
||||
"file": "\\tests\\common\\test_http_transport.py",
|
||||
"_justification": "Test containing fake passwords"
|
||||
},
|
||||
{
|
||||
"file": "\\azure-iot-device\\tests\\iothub\\shared_client_tests.py",
|
||||
"file": "\\tests\\iothub\\shared_client_tests.py",
|
||||
"_justification": "Test containing fake signed data"
|
||||
},
|
||||
{
|
||||
"file": "\\azure-iot-device\\tests\\iothub\\client_fixtures.py",
|
||||
"file": "\\tests\\iothub\\client_fixtures.py",
|
||||
"_justification": "Test containing fake keys and fake signed data"
|
||||
},
|
||||
{
|
||||
"file": "\\azure-iot-device\\tests\\iothub\\test_sync_clients.py",
|
||||
"file": "\\tests\\iothub\\test_sync_clients.py",
|
||||
"_justification": "Test containing fake signed data"
|
||||
},
|
||||
{
|
||||
"file": "\\azure-iot-device\\tests\\iothub\\aio\\test_async_clients.py",
|
||||
"file": "\\tests\\iothub\\aio\\test_async_clients.py",
|
||||
"_justification": "Test containing fake signed data"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -10,7 +10,13 @@ pip install azure-iot-device
|
|||
```
|
||||
|
||||
## IoT Device SDK developer
|
||||
If you are going to be modifying the codebase (likely because you are working as a developer on the Microsoft Azure IoT Device SDK for Python) you will need a few extras. Thankfully, you can prepare your development environment simply by running the `env_setup.py` script in the repository root. This will install not only relevant development and test dependencies, but also an editable install of the source code, which can then have any code changes immediately reflected in the install.
|
||||
If you are going to be modifying the codebase (likely because you are working as a developer on the Microsoft Azure IoT Device SDK for Python) you will need a few extras. Thankfully, you can prepare your development environment simply by running the following command **from the root**:
|
||||
|
||||
```
|
||||
python scripts/env_setup.py
|
||||
```
|
||||
|
||||
This will install not only relevant development and test dependencies, but also an editable install of the source code, which can then have any code changes immediately reflected in the install.
|
||||
|
||||
It is recommended to use [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/install.html) for Unix-based platforms or [virutalenvwrapper-win](https://github.com/davidmarble/virtualenvwrapper-win) for Windows, in order to easily manage custom environments and switch Python versions, however this is optional.
|
||||
|
||||
|
|
До Ширина: | Высота: | Размер: 15 KiB После Ширина: | Высота: | Размер: 15 KiB |
До Ширина: | Высота: | Размер: 4.4 KiB После Ширина: | Высота: | Размер: 4.4 KiB |
До Ширина: | Высота: | Размер: 3.9 KiB После Ширина: | Высота: | Размер: 3.9 KiB |
До Ширина: | Высота: | Размер: 4.1 KiB После Ширина: | Высота: | Размер: 4.1 KiB |
До Ширина: | Высота: | Размер: 2.4 KiB После Ширина: | Высота: | Размер: 2.4 KiB |
|
@ -1,5 +1,5 @@
|
|||
[pytest]
|
||||
testdox_format = plaintext
|
||||
addopts = --testdox --timeout 20
|
||||
addopts = --testdox --timeout 20 --ignore e2e --ignore tests/e2e
|
||||
norecursedirs=__pycache__, *.egg-info
|
||||
filterwarnings = ignore::DeprecationWarning
|
||||
filterwarnings = ignore::DeprecationWarning
|
|
@ -1,4 +1,5 @@
|
|||
py
|
||||
setuptools>=40.1.0
|
||||
wheel>=0.32.1
|
||||
black
|
||||
pre-commit
|
||||
|
|
|
@ -5,7 +5,7 @@ pytest-testdox>=1.1.1
|
|||
pytest-cov
|
||||
pytest-timeout
|
||||
flake8
|
||||
azure-iot-hub # Only needed for device_e2e
|
||||
azure-iothub-provisioningserviceclient >= 1.2.0 # Only needed for provisioning_e2e
|
||||
azure-eventhub # Only needed for device_e2e
|
||||
psutil # Only needed for device_e2e
|
||||
azure-iot-hub # Only needed for iothub e2e
|
||||
azure-iothub-provisioningserviceclient >= 1.2.0 # Only needed for provisioning e2e
|
||||
azure-eventhub # Only needed for iothub e2e
|
||||
psutil # Only needed for iothub e2e
|
||||
|
|
До Ширина: | Высота: | Размер: 273 KiB После Ширина: | Высота: | Размер: 273 KiB |
|
@ -0,0 +1,17 @@
|
|||
# -------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for
|
||||
# license information.
|
||||
# --------------------------------------------------------------------------
|
||||
"""Build all packages for distribution"""
|
||||
|
||||
|
||||
import sys
|
||||
from subprocess import check_call
|
||||
|
||||
if __name__ == "__main__":
|
||||
target_dir = "./dist"
|
||||
command_sdist = "setup.py sdist --dist-dir={}".format(target_dir)
|
||||
command_bdist_wheel = "setup.py bdist_wheel --dist-dir={}".format(target_dir)
|
||||
check_call([sys.executable] + command_sdist.split())
|
||||
check_call([sys.executable] + command_bdist_wheel.split())
|
|
@ -5,9 +5,6 @@
|
|||
# --------------------------------------------------------------------------
|
||||
"""Prepare development environment
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
from subprocess import check_call, CalledProcessError
|
||||
|
@ -35,16 +32,13 @@ if __name__ == "__main__":
|
|||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
packages = [os.path.dirname(p) for p in glob.glob("azure*/setup.py")]
|
||||
|
||||
# Make sure pip is on the latest version
|
||||
pip_command("install --upgrade pip")
|
||||
|
||||
# Install packages
|
||||
for package_name in packages:
|
||||
# Use an eager upgrade strategy to make sure we have all the latest dependencies.
|
||||
# This way we will be running into any dependency-related bugs before customers do.
|
||||
pip_command("install -U --upgrade-strategy eager -e {}".format(package_name))
|
||||
# Install package
|
||||
# Use an eager upgrade strategy to make sure we have all the latest dependencies.
|
||||
# This way we will be running into any dependency-related bugs before customers do.
|
||||
pip_command("install -U --upgrade-strategy eager -e .")
|
||||
|
||||
# Because we're just installing development environment libraries beyond this point, no need to
|
||||
# be eager in upgrading, as these dependencies are not customer facing.
|
|
@ -4,7 +4,7 @@
|
|||
# license information.
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools import setup, find_namespace_packages
|
||||
import re
|
||||
|
||||
# azure v0.x is not compatible with this package
|
||||
|
@ -28,7 +28,7 @@ with open("README.md", "r") as fh:
|
|||
_long_description = fh.read()
|
||||
|
||||
|
||||
filename = "azure/iot/device/constant.py"
|
||||
filename = "azure-iot-device/azure/iot/device/constant.py"
|
||||
version = None
|
||||
|
||||
with open(filename, "r") as fh:
|
||||
|
@ -53,7 +53,7 @@ setup(
|
|||
description="Microsoft Azure IoT Device Library",
|
||||
license="MIT License",
|
||||
license_files=("LICENSE",),
|
||||
url="https://github.com/Azure/azure-iot-sdk-python/tree/main/azure-iot-device",
|
||||
url="https://github.com/Azure/azure-iot-sdk-python/",
|
||||
author="Microsoft Corporation",
|
||||
author_email="opensource@microsoft.com",
|
||||
long_description=_long_description,
|
||||
|
@ -86,17 +86,8 @@ setup(
|
|||
"janus",
|
||||
"PySocks",
|
||||
],
|
||||
python_requires="!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5, <4",
|
||||
packages=find_packages(
|
||||
exclude=[
|
||||
"tests",
|
||||
"tests.*",
|
||||
"samples",
|
||||
"samples.*",
|
||||
# Exclude packages that will be covered by PEP420
|
||||
"azure",
|
||||
"azure.iot",
|
||||
]
|
||||
),
|
||||
python_requires=">=3.6, <4",
|
||||
packages=find_namespace_packages(where="azure-iot-device"),
|
||||
package_dir={"": "azure-iot-device"},
|
||||
zip_safe=False,
|
||||
)
|
|
@ -1,22 +0,0 @@
|
|||
# -------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for
|
||||
# license information.
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
"""Run tests on all packages, and write output
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
from subprocess import check_call
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# All packages in the monorepo
|
||||
packages = [os.path.dirname(p) for p in glob.glob("azure*/setup.py")]
|
||||
for package_name in packages:
|
||||
command = "pytest {} --junitxml=junit/{}-test-results.xml --cov=azure --cov-report=xml:coverage.xml --cov-report=html:coverage --cov-append".format(
|
||||
package_name, package_name
|
||||
)
|
||||
check_call(command.split())
|